Android - Tools

Updated: 2019-06-26

Develop/Debug

Install adb and fastboot

On Ubuntu/Debian:

$ sudo apt update
$ sudo apt install android-tools-adb android-tools-fastboot

Check version:

$ adb version

Enable "USB Debugging" On Device

Go to "Settings" -> "About phone" -> tap "Build number" 7 times to enable developer mode.

Then go to "Settings" -> "Developer options" to enable "USB Debugging"

List Connected Devices

Connect device to computer(or use the emulator), then run:

$ adb devices

To restart adb server, run:

$ sudo adb kill-server
$ sudo adb start-server

Send Command

If only one hardware device:

$ adb -d <command>

If only one emulator:

$ adb -e <command>

Otherwise, specify serial number, which can be found in $ adb devices output:

$ adb -s <serial_number> <command>

Or set $ANDROID_SERIAL to the serial number.

More about adb: https://developer.android.com/studio/command-line/adb

Connect to device

$ ls /run/user/$UID/gvfs

$XDG_RUNTIME_DIR defaults to /run/user/$UID, so maybe $XDG_RUNTIME_DIR/gvfs

Android devices uses the Media Transfer Protocol(MTP) when connecting via the USB.

Android Studio

Change Options

e.g. increase -Xmx and -Xms for Android Studio to speed it up

Help -> Edit Custom VM Options

Or modify ~/.AndroidStudio/config/options/studio64.vmoptions

Find the Android Studio process

$ jps -lvm | grep AndroidStudio