Difference between revisions of "Android Tools"

From eLinux.org
Jump to: navigation, search
(traceview)
(target-side tools: add reference to sqlite3 tool)
(11 intermediate revisions by 2 users not shown)
Line 2: Line 2:
  
 
== Android SDK ==
 
== Android SDK ==
=== adb ===
+
=== host-side tools ===
 +
==== adb ====
 
adb is the android debugger - it also doubles as file transfer agent.
 
adb is the android debugger - it also doubles as file transfer agent.
 
The setup consists of an <tt>adbd</tt> on the target in the <tt>/sbin</tt> directory. On the host two programs are run: the <tt>adb</tt> application (in the SDK's <tt>tools</tt> directory) and an adb server, started by the adb application.
 
The setup consists of an <tt>adbd</tt> on the target in the <tt>/sbin</tt> directory. On the host two programs are run: the <tt>adb</tt> application (in the SDK's <tt>tools</tt> directory) and an adb server, started by the adb application.
Line 19: Line 20:
 
* <tt>tools/adb devices</tt> should now list the device.
 
* <tt>tools/adb devices</tt> should now list the device.
  
=== aapt ===
+
==== aapt ====
 
The Android Asset Packaging Tool is used to create, inspect and manage Android packages.
 
The Android Asset Packaging Tool is used to create, inspect and manage Android packages.
  
Line 28: Line 29:
 
See [[Android aapt]] for substantially more information.
 
See [[Android aapt]] for substantially more information.
  
 +
==== ddms ====
 +
The Dalvik Debug Monitor Server is a host-based tool which interacts with and Android target system
 +
and can show numerous bits of information, including the log, cpu and memory utilization, and
 +
lots of details about individual processes.
  
=== fastboot ===
+
See the [http://developer.android.com/guide/developing/tools/ddms.html DDMS developer guide]
* Fastboot - [[Android Fastboot]] is a tool to boot and manipulate the partitions on an Android development phone.
+
  
* toolchains -  
+
 
* logging system -  
+
==== Fastboot ====
 +
[[Android Fastboot]] is a tool to boot and manipulate the partitions on an Android development phone.
 +
 
 +
==== Toolchains ====
 +
Android provides pre-built toolchains (C/C++ compilers and linkers), but requires the installation of a java compiler (JDK) from an external source.
 +
 
 +
As of NDK version r5 (December 2010), the toolchains can now be used in standalone cross-compiler mode.
 +
See docs/STANDALONE-TOOLCHAIN.html in the NDK for information about this.  Previously, the toolchains
 +
could be used within the build system, but it was difficult and error prone to compile native programs outside the Android build system with them.
 +
 
 +
==== Emulator ====
 
* Emulator - See http://developer.android.com/guide/developing/tools/emulator.html
 
* Emulator - See http://developer.android.com/guide/developing/tools/emulator.html
 +
 
The emulator is a version of QEMU, which mimics the instruction set of an ARM processor, and  
 
The emulator is a version of QEMU, which mimics the instruction set of an ARM processor, and  
 
the hardware that one might find on a mobile phone.  The emulator runs on an x86 system,
 
the hardware that one might find on a mobile phone.  The emulator runs on an x86 system,
Line 47: Line 62:
 
** real hardware
 
** real hardware
  
=== traceview ===
+
==== traceview ====
 
* Google's main page describing traceview: http://developer.android.com/guide/developing/tools/traceview.html
 
* Google's main page describing traceview: http://developer.android.com/guide/developing/tools/traceview.html
 
* http://www.bottomlesspit.org/file_download/2/Android_SDK_Traceview_tool.pdf - good overview presentation by Olivier Bilodeau
 
* http://www.bottomlesspit.org/file_download/2/Android_SDK_Traceview_tool.pdf - good overview presentation by Olivier Bilodeau
 
** presentation with speaker notes: http://www.bottomlesspit.org/file_download/3/Android_SDK_Traceview_tool_w_speakernotes.pdf
 
** presentation with speaker notes: http://www.bottomlesspit.org/file_download/3/Android_SDK_Traceview_tool_w_speakernotes.pdf
 
* [http://newfoo.net/2009/04/18/performance-tuning-android-applications.html Performance Tuning Android Applications] - straightforward article discussing traceview use to find an application bottleneck. April 2009.
 
* [http://newfoo.net/2009/04/18/performance-tuning-android-applications.html Performance Tuning Android Applications] - straightforward article discussing traceview use to find an application bottleneck. April 2009.
 +
 +
=== target-side tools ===
 +
==== am ====
 +
Activity Manager - can be used to start applications at the command line, or send intents to
 +
running applications.
 +
 +
==== dumpstate ====
 +
dumps the state of the system.  It scans the /proc filesystem, and collects various system properties, and puts them in a single report, suitable for sending to someone for support or development help.
 +
 +
==== logcat ====
 +
This is the user tool for accessing the Android system log.  This is implemented at a special
 +
option in adb (I'm not sure what the difference is between "adb logcat" and "adb shell logcat")
 +
 +
You can find lots of information about logcat on the [[Android logger]] page, and at
 +
http://developer.android.com/guide/developing/tools/adb.html#logcat
 +
 +
==== monkey ====
 +
==== procrank ====
 +
procrank shows a listing of processes on the system, sorted by one of the memory utilization
 +
metrics.  See [[Android Memory Usage#procrank]]
 +
 +
==== service ====
 +
Can be used to send an individual service message.
 +
 +
<pre>
 +
Usage: service [-h|-?]
 +
      service list
 +
      service check SERVICE
 +
      service call SERVICE CODE [i32 INT | s16 STR] ...
 +
Options:
 +
  i32: Write the integer INT into the send parcel.
 +
  s16: Write the UTF-16 string STR into the send parcel.
 +
</pre>
 +
 +
On one forum, I saw that you could switch between portrait and landscape with:
 +
$ service call window 18 i32 1 # to set to landscape on the emulator
 +
$ service call window 18 i32 0 # to set to portrait on the emulator
 +
 +
service list will show a list of different services that can be communicated with.
 +
==== sqlite3 ====
 +
sqlite3 is a command-line database client program, for manipulating sqlite databases.
 +
 +
See http://www.higherpass.com/Android/Tutorials/Accessing-Data-With-Android-Cursors/ for a tutorial and
 +
some examples of using sqlite.
 +
 +
==== toolbox ====
 +
stop, start - commands to stop and start services on an Android system
  
 
== other tools ==
 
== other tools ==
Line 58: Line 120:
 
** See http://android-tricks.blogspot.com/2009/02/hello-world-c-program-on-using-android.html
 
** See http://android-tricks.blogspot.com/2009/02/hello-world-c-program-on-using-android.html
 
=== bootchart ===
 
=== bootchart ===
* [[Using Bootchart on Android|bootchart]]
+
* See [[Using Bootchart on Android]]
  
 
=== busybox ===
 
=== busybox ===
Line 67: Line 129:
  
 
=== smem ===
 
=== smem ===
* smem
+
* smem - smem is a tools for analyzing the memory usage on a system
 +
** See [[Using smem on Android]] for more information
  
 
=== strace ===
 
=== strace ===
Line 75: Line 138:
  
 
== Eclipse ==
 
== Eclipse ==
 +
 +
The officially supported integrated development environment (IDE) is [http://www.eclipse.org/ Eclipse] (currently 3.4 or 3.5) using the Android Development Tools (ADT) Plugin, though developers may use any text editor to edit Java and XML files then use command line tools (Java Development Kit and Apache Ant are required) to create, build and debug Android applications as well as control attached Android devices (e.g., triggering a reboot, installing software package(s) remotely).
  
 
== Hardware ==
 
== Hardware ==

Revision as of 16:42, 14 October 2011

Here are some development tools useful for working with Android

Android SDK

host-side tools

adb

adb is the android debugger - it also doubles as file transfer agent. The setup consists of an adbd on the target in the /sbin directory. On the host two programs are run: the adb application (in the SDK's tools directory) and an adb server, started by the adb application.

For emulators, adb will usually run automagically.

For real boards - with debugging over USB, you might need to do work, as is documented here: http://developer.android.com/guide/developing/device.html#setting-up .

For real boards that do not have a USB connection but have Ethernet instead, you might need to do a few tricks.

  • make sure that adbd runs on the board. If it doesn't run, you might want to check the init.rc file.
  • make sure that the network connection between host and the board is working - test pinging both ways.
  • on the host, type the following (and yes, you need to specify the board's IP address on the host):
  ADBHOST=<target-ip> tools/adb kill-server
  ADBHOST=<target-ip> tools/adb shell
  • you should now get a prompt on the board, you can exit the prompt if you want.
  • tools/adb devices should now list the device.

aapt

The Android Asset Packaging Tool is used to create, inspect and manage Android packages.

You can use this to see details about a package, it's resources, and xml information.

The Android developer page on aapt is somewhat meager.

See Android aapt for substantially more information.

ddms

The Dalvik Debug Monitor Server is a host-based tool which interacts with and Android target system and can show numerous bits of information, including the log, cpu and memory utilization, and lots of details about individual processes.

See the DDMS developer guide


Fastboot

Android Fastboot is a tool to boot and manipulate the partitions on an Android development phone.

Toolchains

Android provides pre-built toolchains (C/C++ compilers and linkers), but requires the installation of a java compiler (JDK) from an external source.

As of NDK version r5 (December 2010), the toolchains can now be used in standalone cross-compiler mode. See docs/STANDALONE-TOOLCHAIN.html in the NDK for information about this. Previously, the toolchains could be used within the build system, but it was difficult and error prone to compile native programs outside the Android build system with them.

Emulator

The emulator is a version of QEMU, which mimics the instruction set of an ARM processor, and the hardware that one might find on a mobile phone. The emulator runs on an x86 system, but executes an ARM linux kernel and programs. The flow of control is:

    • application ->
    • dalvik VM ->
    • C/C++ libraries ->
    • ARM linux kernel ->
    • emulated instructions and hardware (QEMU)->
    • C libraries->
    • x86 kernel ->
    • real hardware

traceview

target-side tools

am

Activity Manager - can be used to start applications at the command line, or send intents to running applications.

dumpstate

dumps the state of the system. It scans the /proc filesystem, and collects various system properties, and puts them in a single report, suitable for sending to someone for support or development help.

logcat

This is the user tool for accessing the Android system log. This is implemented at a special option in adb (I'm not sure what the difference is between "adb logcat" and "adb shell logcat")

You can find lots of information about logcat on the Android logger page, and at http://developer.android.com/guide/developing/tools/adb.html#logcat

monkey

procrank

procrank shows a listing of processes on the system, sorted by one of the memory utilization metrics. See Android Memory Usage#procrank

service

Can be used to send an individual service message.

Usage: service [-h|-?]
       service list
       service check SERVICE
       service call SERVICE CODE [i32 INT | s16 STR] ...
Options:
   i32: Write the integer INT into the send parcel.
   s16: Write the UTF-16 string STR into the send parcel.

On one forum, I saw that you could switch between portrait and landscape with:

$ service call window 18 i32 1 # to set to landscape on the emulator
$ service call window 18 i32 0 # to set to portrait on the emulator

service list will show a list of different services that can be communicated with.

sqlite3

sqlite3 is a command-line database client program, for manipulating sqlite databases.

See http://www.higherpass.com/Android/Tutorials/Accessing-Data-With-Android-Cursors/ for a tutorial and some examples of using sqlite.

toolbox

stop, start - commands to stop and start services on an Android system

other tools

agcc

bootchart

busybox

Android ships with a utility suite (called 'toolbox') that is not busybox.

You can get a binary busybox for Android here The site includes instructions for easy installation on your device.

smem

  • smem - smem is a tools for analyzing the memory usage on a system

strace

Eclipse

The officially supported integrated development environment (IDE) is Eclipse (currently 3.4 or 3.5) using the Android Development Tools (ADT) Plugin, though developers may use any text editor to edit Java and XML files then use command line tools (Java Development Kit and Apache Ant are required) to create, build and debug Android applications as well as control attached Android devices (e.g., triggering a reboot, installing software package(s) remotely).

Hardware

Serial Cable for G1

You can build a serial cable to use with the G1, which is helpful to see kernel boot messages on the serial console.

See http://www.instructables.com/id/Android_G1_Serial_Cable

Back to Android Portal