adb tidbits

This is a short post with few useful tips you may use while working with adb. If you are an experienced Android developer probably you had to issue these commands several times.

1 – Kill the server

Sometimes it can happen that your device is not listed by adb anymore and it’s impossible to get logs or install applications.

Remember that adb is a client-server program and the server side manages communication between the client and the adb daemon running on an emulator or device.

So, in those situations, simply try to terminate the adb server process:

adb kill-server

To restart it, you can do it explicitly issuing the following command:

adb start-server

or you can directly try to list the available devices (server will be automatically started):

adb devices

2 – Replace an application

When you manually install an application on a device, you could get this error:


It means an application with the same package name is already present on the device.
Using a specific option, you can tell adb to replace the existing application with the one you passing in input. Private application data is preserved:

adb install -r FILENAME.apk

3 – Getting temporary permission

Sometimes you may need to have a look at the private application data folder on the device, for example to simply list its content.

If you’re not using an emulator or a rooted device, you don’t have access to this location because you lack the necessary permissions.

That’s where adb comes to the rescue.

First of all, you have to start a remote shell in the target device:

adb shell

Then, you have to ask to run further commands as if you were a specific application, passing its package name. Of course, you have to use the correct name for the application you’re going to inspect. Please keep in mind that the application has to be debuggable:

adb run-as example.
adb run-as example.

Leave a Reply

Your email address will not be published. Required fields are marked *