Android and developer mode: how to use ADB

Android has a large number of options that are a little hidden and not necessarily useful to everyone. Mainly there to help developers, some of these tools can be potentially useful to everyone. Indeed, thanks to the tools for developers, you can do various and varied things, like taking screenshots, asking that the screen never go to sleep when the smartphone is charging, or even installing applications via USB, and even make a video of your screen.

This list is obviously far from exhaustive, and in this tutorial we will see how to use Android developer's best friend: ADB, which will allow you to act on your Android terminal from your computer.

Android And Developer Mode How To Use Adb

Developer options can be very useful

Developer options

Previously, developer options were available to everyone. However, this has changed for a few versions of Android where you have to enable developer mode before you can take advantage of these same options.

To find out if you have access to these options, your best bet is still to go to your terminal settings and look at the end of the list: if you see an entry like “ Developer options ”, it is is won. Otherwise, you must activate developer mode.

This activation can be done very simply. Still in your terminal settings, go to what should be the last entry: “ About phone “. Look for the entry “ Build number ”, which should also be at the end of the list.

Then tap this entry several times. Small notifications should appear every now and then before a message finally pops up telling you that “ you are now a developer ”. Good news, you won't have to do a rain dance to complete the ritual: you already have access to developer options.

Android And Developer Mode How To Use Adb

Activating developer options: quite a ritual!

If you want to turn off those options and completely remove the new menu entry for some reason or another, that's pretty straightforward. Still in the settings of your device, this time go to the applications menu and look for “ Settings ” or “ Settings ” depending on your device. Select that entry, click on the “ Clear data ” button, and you're done.

ADB, a friend who wants you well

ADB stands for Android Debug Bridge and, as the name suggests, will allow developers to debug Android applications. However, as the name does not suggest, ADB actually allows a lot more to be done, and its usefulness thus goes beyond developers.

First thing, you need ADB installed on your computer. There are several methods for this, depending on your operating system (Ubuntu offers for example a package allowing you to install only ADB). The most universal is to take a look at the Android SDK offered by Google and available at this address. For ADB, you can limit yourself to downloading only the “ SDK Tools ”.

We now go through the command line. To do this, open a terminal (or a command prompt in Windows). Using the cd command, navigate to the folder containing the ADB executable (the same one you just downloaded or one of its subfolders). Note that this action becomes unnecessary if ADB is located in a folder contained in the PATH, but we will not dwell on this point.

In the following, the commands that I will give will start simply with adb . However, depending on your installation, you may need to specify ./adb or adb.exe .

In any case, before you can play with ADB, you will need to activate a small option that will change everything on your Android terminal: USB debugging, which you will find in the developer options activated previously. Enabling USB debugging will allow you to use ADB to produce actions on your terminal from your computer.

ADB, the basics: find your terminal

First thing to do: connect your Android terminal to USB and start the ADB server. To do this, in your terminal, simply type the command adb start-server . Next, enter the adb devices command, which will display the list of all Android devices connected adb devices USB (which also works with Android Wear devices, but we had already discussed this ).

There is a little subtlety here. You should normally see your terminal, with a somewhat odd serial number followed by an indication, readable this time. If you read the indication “ offline ”, no need to go any further: nothing you do will work.

Your terminal is of course connected, and this is not the problem: you should actually start the ADB server with administrator rights (under Ubuntu for example I have never succeeded otherwise). So you launch adb start-server with root rights, and you're done. The rest can be done without root rights.

To restart the server, it's simple, just shut down with adb kill-server and turn on again with what we saw above.

If you only have one Android device connected, the rest will be easier, but be aware that nothing prevents you from connecting multiple devices. Of course, for each ADB command launched, you will have to target the right terminal …

Rest assured though: it's not particularly complicated. Indeed, all the commands that we will launch will be of the type adb [commande à exécuter] : in the rest of this tutorial and in the others that will talk about ADB, I will always offer my commands in this form, and it is in this form. here you will have to run them if you only have one terminal connected.

On the other hand, you will have to add a little something if you have more than one: adb -s [numéro du terminal] [commande à exécuter] , the terminal number being the one you get in the list of adb devices . For example, if I want to open a command prompt from my Android smartphone while my smartwatch is also connected, I can run adb -s BH90TFM816 shell .

Note that nothing prevents you from using the -s option even if you only have one terminal connected, but it's a bit complicated!

A few commands to warm up

We are not going to make here the exhaustive list of all the possible orders via ADB. There are a lot of them and they clearly won't be useful to everyone. If however you wanted to see this complete list, I can only advise you to type the command adb help which has exactly this purpose.

You might be interested in exchanging files between your computer and your Android device. While on most operating systems this is possible in graphical mode, ADB has certain advantages, such as being able to be used in scripts for example, and it can be useful to know how to do this.

To send a file to your Android terminal, simply run the adb push [fichier à envoyer] [chemin sur le terminal] command. Do not forget of course the intricacies of calling ADB mentioned above, in particular the -s option if you have several terminals connected. For example, if I want to send the video chatons.mp4 to my smartphone, tidy in a folder, I can type adb push chatons.mp4 /sdcard/Videos/ .

Receiving a file found on the Android terminal is not much more complicated: adb pull [fichier à réceptionner] [chemin local] . You can even do without the local path which is only used to indicate the path where to store the file (and possibly the new name of the file). By default, it will be received in the current folder. An example ? I want to retrieve my kittens video: adb pull /sdcard/Videos/chatons.mp4 , and adb pull /sdcard/Videos/chatons.mp4 .

Note that these file exchanges are of course copies: sending a file will not delete it from your computer and receiving one will not delete it from your Android device.

Developers will still be able to look for the install option which allows installing an APK file stored on the computer directly to the Android terminal and, if you are looking for something very powerful, you can look for the option. shell .

As the name suggests, this last option will allow you to open a command prompt where whatever you type will be executed on the Android terminal. The command prompt can be opened simply with adb shell . If you want to execute only one command, it is also possible by doing adb shell [commande à exécuter] .

It's your turn

Here we have laid the foundations of ADB. As already said, this tutorial was not intended to be exhaustive as to the multiple possibilities of the tool. However, you already have a lot of fun, especially with the shell option. In future tutorials, we will come back to specific options that deserve some attention.

0 replies on “Android and developer mode: how to use ADB”