4.2.1. General Hints

4.2.1.1. Prepare device

You have to prepare your device for debugging. For Android 4.2+ tap Build number seven times:

  • Settings ‣ About phone ‣ Build number

Developer options appears now:

  • Settings ‣ Developer options

Note

Go to Developer options and turn it ON:

  • Settings ‣ Developer options ‣ Developer options

Also turn ON debug mode when USB is connected. Otherwise adb will not be able to discover the device:

  • Settings ‣ Developer options ‣ USB debugging

4.2.1.2. Get Android NDK

Polly

Android NDK contains compilers and other tools for C++ development.

4.2.1.3. Get Android SDK

Android SDK tools used for development on Android platform: adb, android, emulator, etc.

4.2.1.4. Verify

Connect device with USB and verify it’s visible by adb service:

> adb devices
List of devices attached
MTPxxx device

If service is not started there will be extra messages:

> adb devices
List of devices attached
* daemon not running. starting it now on port 5037 *
* daemon started successfully *
MTPxxx device

4.2.1.5. SDK version on device

The needed version of SDK can be get by reading ro.build.version.sdk:

> adb -d shell getprop ro.build.version.sdk
19

Means you need to use API 19.

Note

  • -d is for real device

  • -e is for emulator

4.2.1.6. CPU architecture

Run next command to determine CPU architecture of emulator:

> adb -e shell getprop ro.product.cpu.abi
x86

And this one for device:

> adb -d shell getprop ro.product.cpu.abi
armeabi-v7a

4.2.1.7. Log

See also

Clear log:

> adb logcat -c

Filter only Info (I) messages from SimpleApp, ignore others and exit:

> adb logcat -d SimpleApp:I '*:S'
--------- beginning of /dev/log/main
--------- beginning of /dev/log/system
I/SimpleApp( 9015): Hello from Android! (Not debug)
>

Any messages from SimpleApp, ignore others:

> adb logcat -d 'SimpleApp:*' '*:S'
--------- beginning of /dev/log/main
--------- beginning of /dev/log/system
I/SimpleApp( 9015): Hello from Android! (Not debug)
>