Android Developer FAQs
Content is no longer maintained and is being kept for reference only!
This is wiki guide covering android developer FAQs. The goal of this guide is to cover all commonly faced problems while porting android on custom hardware.
Note: Answers suggested here might not be "The Solution" - As it depends on other environment variables. Also some of the answers and conclusion has been taken from online (group/forum) discussions.
- 1 Booting
- 2 Android System
- 2.1 Q: init.rc tutorial. Android initialization process
- 2.2 Q: How to port an Android on ARM based SoC?
- 2.3 Q: Where to add custom property in Android?
- 2.4 Q: What is android property architecture ?
- 2.5 Q: How to create custom service in Android ?
- 2.6 Q:logcat is not working. Command "ls /sys/kernel/logger" return error. What is the catch?
- 2.7 Q:How to write a script, which can run after android boot?
- 2.8 Q: How to set http-proxy proxy sqlite3 in android ?
- 2.9 Q: How does touchscreen or keyboard event process in android ? Input event handling in android
- 2.10 Q: How to see apk contents ?
- 2.11 Q: How to change android start language ?
- 2.12 Q: How to access (read and write) linux tty serial port using Android API ?
- 3 Memory
- 4 Debug & Log
- 5 Peripherals
- 5.1 Q: How to port wifi driver to Android device?
- 5.2 Q: How to configure keypad on Android device?
- 5.3 Q: How to get GPIO Keypad working ?
- 5.4 Q: How to get USB Event and change node permission in android ?
- 5.5 Q: How to get USB stick installed ? How to install apk residing on USB stick ?
- 5.6 Q:How to add/configure LCD touchscreen ?
- 5.7 Q:How to add or port radio layer interface on android ?
- 5.8 Q:How to add ethernet support in settings for android gingerbread ?
- 5.9 Q:How to come out of Airplane mode ?
- 5.10 Q: Sliding to camera gives error on ICS unlock screen
- 6 Build Errors
- 7 Others
- 7.1 Q:How to start android application from command line or console ?
- 7.2 Q: How to auto disable key guard/screen lock after android boot? How to see home screen instead of screen lock after android boot ?
- 7.3 Q:Any link for getting started on porting android for new mobile device ?
- 7.4 Q: How to use mplayer command to play the camera video?
- 7.5 Q: How to launch a video/audio clip from gallery from command line?
- 7.6 Q: I get this error: ./mkmmc-android.sh: /bin/bash^M: bad interpreter: No such file or directory
- 7.7 Q: How to read contents of boot.scr
- 7.8 Q: Android Tips to improve user experience
- 7.9 Q: How to switch off android device from console ?
- 8 Benchmark
- 9 References
Q: While booting, kernel boots fine but problem comes when actual Android processes start.Following logs appears on the screen.
"init: process 'servicemanager', pid 879 exited"
Ans: There could be various reasons.But most frequent problem is - android log driver is disable inside kernel.Kindly try to set loglevel 8 in init.rc and reboot.If same message appears then 99% problem is the same as described. Kindly enable log driver and try.
Location: -> Device Drivers -> Staging drivers (STAGING [=y]) -> Exclude Staging drivers from being built (STAGING_EXCLUDE_BUILD [=n]) -> Android -> Android Drivers (ANDROID [=y])
Q: init.rc tutorial. Android initialization process
Q: How to port an Android on ARM based SoC?
Q: Where to add custom property in Android?
Ans: Kindly refer "dalvik/vm/Properties.c" file.
Property can be added inside function "dvmCreateDefaultProperties" @dalvik/vm/Properties.c file. e.g. setProperty(propObj, put, <prop_name>, <prop_value>);
Q: What is android property architecture ?
Ans: : Very good explain given by rxwen at
Q: How to create custom service in Android ?
Ans: : Wiki guide & few references are mentioned below
Q:logcat is not working. Command "ls /sys/kernel/logger" return error. What is the catch?
Ans: Quick note: logcat is driven by “/dev/log/*” fs entries., (probably /sys/kernel/logger is obsolete now)
Try launching a valid console service with root permission @init.rc service console /system/bin/sh console disabled user root group log Also, cross check permissions for /dev/log? #cd /dev/log #ls -l l* drwxr-xr-x root root 2000-01-02 20:08 log #cd log #ls –l * # ls -l crw-rw--w- root log 10, 52 2000-01-02 20:08 system crw-rw--w- root log 10, 53 2000-01-02 20:08 radio crw-rw--w- root log 10, 54 2000-01-02 20:08 events crw-rw--w- root log 10, 55 2000-01-02 20:08 main One can check what are being set in /ueventd.rc # logger should be world writable (for logging) but not readable /dev/log/* 0662 root log
Q:How to write a script, which can run after android boot?
Below scenario explains how usb drive can be auto mount using script.
In your init.rc add: ------------------------------------ +mkdir /usbmountd +service usbmountd /system/bin/usbmountd + disabled +on device-added-/dev/sda1 + start usbmountd ------------------------------------ Create/edit /system/bin/usbmountd script as: ------------------------------------ #!/system/bin/sh case "$1" in "start") mount -t vfat /dev/block/sda1 /usbmountd ;; "stop") sync umount /dev/block/sda1 ;; *) echo "$0: unknown argument $1." >&2; ;; esac ------------------------------------ Once the device is mounted you can browse through the files from any of the available Android file manager applications because your device won't be mounted as External Storage and won't be auto scanned for media files. http://groups.google.com/group/android-porting/msg/bd03acbe5ddfa2ae
Q: How to set http-proxy proxy sqlite3 in android ?
Q: How does touchscreen or keyboard event process in android ? Input event handling in android
Q: How to see apk contents ?
Ans: : jar -tvf <apk-name>.apk
Q: How to change android start language ?
Ans: : Kindly refer the link #http://e2e.ti.com/support/embedded/f/509/p/141407/510287.aspx#510287
Q: How to access (read and write) linux tty serial port using Android API ?
Ans: : Refer to the project #http://code.google.com/p/android-serialport-api/wiki/Building_the_project android-serialport-api
Q:How to do auto mount sdcard ?
Ans: : One need to modify entry in /etc/vold.fstab.
dev_mount sdcard <mount location> <partition number> <mmc entry><br> e.g. For data created at partition#3, one need to put following entry in /etc/vold.fstab<br> dev_mount sdcard /mnt/sdcard 3 /devices/platform/mmci-omap-hs.0/mmc_host/mmc0
Q:Where to locate memory footprint of android ?
Ans: : Refer "build/core/prelink-linux-arm.map" file
Q: How to use generic audio ?
Ans: : Sometime we face default AudioFlinger service can't start correctly and enters a loop showing the following messages:
I/ServiceManager( 866): Waiting for sevice media.audio_policy... I/ServiceManager( 866): Waiting for sevice media.audio_policy... W/AudioSystem( 866): AudioPolicyService not published, waiting...
Instead of rebuilding the full Android root file system, this problem can be quickly fixed with the following procedure: 1) edit the frameworks/base/services/audioflinger/Android.mk file adding on top:
BOARD_USES_GENERIC_AUDIO := true BOARD_USES_ALSA_AUDIO := false
2) rebuild AudioFlinger with the following commands:
#source build/envsetup.sh #mmm -B frameworks/base/libs/audioflinger
This will need some dependencies to be satisfacted. The fastest way is by copying the libraries from the prebuilt root file system into the out/target/product/generic/system/lib/ and out/target/product/generic/obj/lib/ directories.
3) Once compiled, simply copy the file out/target/product/generic/obj/lib/libaudioflinger.so on the prebuilt root file system, overwriting the previous version
Debug & Log
Q: How to debug android crash?
Ans: : There are various technique available @ http://developer.android.com/guide/developing/debug-tasks.html.But at times when system/service/application or any other crash, it would be easy if we can get line number from crash address.
#arm-none-linux-gnueabi-addr2line -f -e <.so path> <address> ex. #arm-none-linux-gnueabi-addr2line -f -e ~/rowboat-android/out/target/product/beagleboard/system/lib/libcamera.so 0x000043a8 /* will give line number of last accessed address @ crashed point */
TI porting guide available at
Q: How to port wifi driver to Android device?
Ans: : Kindly refer 'Porting WiFi drivers to Android'
- Most common mistake while porting wifi device :
Q: How to configure keypad on Android device?
Ans: : Kindly refer link# http://www.lindusembedded.com/blog/2011/02/15/configuring-a-custom-gpio-based-keypad-in-android/
Q: How to get GPIO Keypad working ?
Ans: : The GPIO keypad driver example is at
Please use this to implement a keypad driver, Check the events on Android console ( using command #getevent). Once one start getting the events then one should modify the .kl file in Android (device/ti/<yourboard>/<keypad driver name>.kl file and map the keys accordingly in decimal format because getevent show in hex format. Example->
device/ti/am335xevm/gpio-keys.kl key 256 MENU WAKE
- where key is common key word
- where 256 is decimal equivalent of the value obtained through getevent
- where MENU is Android key Code
- where WAKE is policy flag, stating that this key can wake the device up
Q: How to get USB Event and change node permission in android ?
Create ueventd.<yourboard>.rc file in (device/ti/yourboard/) folder and copy this file in root directry of filesystem with the help of device.mk file create a copy entry below in PRODUCT_COPY_FILES line device.mk file.
add the line ueventd.<yourboard>.rc file /dev/video0 0666 root root
- where /dev/video0 is node
- where 0666 is premission
- where root is system
- where root is radio
Q: How to get USB stick installed ? How to install apk residing on USB stick ?
a) In the init.rc file do the following changes as shown with '+' sign (patch)
# mount sdcard third partition on /part-3 mkdir /part-3 + mkdir /usbmountd mount vfat /dev/block/mmcblk0p3 /part-3/ # mount mtd partitions @@ -361,6 +369,9 @@ on property:persist.service.adb.enable=0 stop adbd +on device-added-/dev/block/sda + service usbmountd /system/bin/usbmountd start + service servicemanager /system/bin/servicemanager user system critical
b) Create a new file /system/bin/usbmountd and copy the below
#!/system/bin/sh case "$1" in "start") mount -t vfat /dev/block/sda1 /usbmountd ;; "stop") sync umount /dev/block/sda1 ;; *) echo "$0: unknown argument $1." >&2; ;; esac
Make sure that /system/bin/usbmountd has executable permissions
c) Use the Filemanager app#http://openintents.googlecode.com/files/FileManager-1.1.4.apk,when you browse the USB folder, it should show the .apk file, just click on this, it will install the application on the device directly.
Q:How to add/configure LCD touchscreen ?
Q:How to add or port radio layer interface on android ?
Q:How to add ethernet support in settings for android gingerbread ?
Ans:Refer to patch given at#http://blog.linuxconsulting.ro/2011/06/ethernet-patch-for-android-gingerbread.html
Q:How to come out of Airplane mode ?
Ans:On our platforms it is currently not possible to disable Airplane mode if it is enabled.
To reset the Airplane mode setting, follow the following steps:
Boot the device and on the serial console (or adb shell console), enter the following commands shown in bold:
# sqlite3 /data/data/*/*/settings.db SQLite version 3.6.22 Enter ".help" for instructions Enter SQL statements terminated with a ";" sqlite> delete from system where name='airplane_mode_on'; sqlite> .exit #
Reboot the board. Now the Airplane mode setting is reset.
Q: Sliding to camera gives error on ICS unlock screen
Ans: Make sure that the camera module as appropriate is correctly installed on the board.
If your device not have a camera, you can set android to use the stub camera as follows:
sudo cp <rootfs path>/system/lib/hw/camera.goldfish.so <rootfs path>/system/lib/hw/camera.default.so
Ensure that camera.omap3.so is not present in /system/lib/hw directory, if you do not wish to support camera module. Only camera.default.so should be present.
Build error on 64-bit machine
One need to have following packages to be installed in order to build android on 64-bit machine.
64-bit: sudo apt-get install git-core gnupg flex bison gperf build-essential zip curl zlib1g-dev libc6-dev g++-multilib lib32ncurses5-dev ia32-libs x11proto-core-dev libx11-dev lib32readline5-dev lib32z-dev libgl1-mesa-dev libsdl-dev sun-java5-jdk libesd0-dev libwxgtk2.6-dev libncurses5-dev zlib1g-dev tftpd uboot-mkimage
[out/target/common/obj/APPS/BluetoothSCOApp_intermediates/classes-full-debug.jar] Error 41 make: *** Waiting for unfinished jobs.... out/target/common/obj/APPS/Calculator_intermediates/src/com/android/calculator2/R.java:10: cannot access java.lang.Object bad class file: java/lang/Object.class(java/lang:Object.class) unable to access file: corrupted zip file
Ans: run "sudo update-alternatives --config jar" and select the corresponding jar tool from the 1.6 JDK you're using. This should fix things enough for you to do a clean build of things at that point.
host C: acp <= build/tools/acp/acp.c In file included from /usr/include/features.h:388:0, from /usr/include/stdlib.h:25, from build/tools/acp/acp.c:11: /usr/include/gnu/stubs.h:7:27: fatal error: gnu/stubs-32.h: No such file or directory compilation terminated. make: *** [out/host/linux-x86/obj/EXECUTABLES/acp_intermediates/acp.o] Error 1
$sudo apt-get install libc6-dev-i386
Error: cannot stat pvrsrvkm.ko
cp: cannot stat `android/hardware/ti/sgx/eurasiacon/binary2_omap4430_android_release/target/pvrsrvkm.ko': No such file or directory make: *** [buildkernel] Error 1 make: Leaving directory `android/hardware/ti/sgx' make: *** [sgx] Error 2
Ans: Go to "android/hardware/ti/sgx/"
Apply this following patch:
From 0eb2b92716e27e3ef60661ecbbc678dd4a23f046 Mon Sep 17 00:00:00 2001 From: Umakanta Patro <firstname.lastname@example.org> Date: Wed, 29 Aug 2012 15:55:13 +0530 Subject: [PATCH] Solve issues with OUT variable This patch fixes the following issue: cp: cannot stat `android/hardware/ti/sgx/eurasiacon/binary2_omap4430_android_release/target/pvrsrvkm.ko': No such file or directory Signed-off-by: hedwin <email@example.com> Signed-off-by: Umakanta Patro <firstname.lastname@example.org> --- eurasiacon/build/linux2/config/core.mk | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/eurasiacon/build/linux2/config/core.mk b/eurasiacon/build/linux2/config/core.mk index bf9e0b9..2d56b1a 100644 --- a/eurasiacon/build/linux2/config/core.mk +++ b/eurasiacon/build/linux2/config/core.mk @@ -179,7 +179,7 @@ $(call directory-must-exist,$(TOP)/eurasiacon/build/linux2/$(PVR_BUILD_DIR)) # final programs/libraries, and install/rc scripts. # BUILD ?= release -OUT ?= $(TOP)/eurasiacon/binary2_$(PVR_BUILD_DIR)_$(BUILD) +OUT := $(TOP)/eurasiacon/binary2_$(PVR_BUILD_DIR)_$(BUILD) override OUT := $(if $(filter /%,$(OUT)),$(OUT),$(TOP)/$(OUT)) CONFIG_MK := $(OUT)/config.mk -- 220.127.116.11
Q:How to start android application from command line or console ?
am start -a <action> -n <component>/<intent> am start -a android.intent.action.MAIN -n package/class_fullname e.g. am start -a android.intent.action.MAIN -n com.android.settings/.Settings
Q: How to auto disable key guard/screen lock after android boot? How to see home screen instead of screen lock after android boot ?
Ans: Kindly apply following patch in frameworks/base and rebuild your android system.
With this patch applied, the keyguard will not appear on boot or after suspend-resume. Signed-off-by: Vishveshwar Bhat <email@example.com> --- .../internal/policy/impl/KeyguardViewMediator.java | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-) diff --git a/policy/src/com/android/internal/policy/impl/KeyguardViewMediator.java b/policy/src/com/android/internal/policy/impl/KeyguardViewMediator.java index 9d10ce5..fbfc817 100644 --- a/policy/src/com/android/internal/policy/impl/KeyguardViewMediator.java +++ b/policy/src/com/android/internal/policy/impl/KeyguardViewMediator.java @@ -553,7 +553,7 @@ public class KeyguardViewMediator implements KeyguardViewCallback, } if (DEBUG) Log.d(TAG, "doKeyguard: showing the lock screen"); - showLocked(); + //showLocked(); } } -- 1.7.1
Q: How to use mplayer command to play the camera video?Ans:
#mplayer tv:// -tv driver=v4l2:width=480:height=272:device=/dev/video0
Q: How to launch a video/audio clip from gallery from command line?
$am start -n com.android.gallery/com.android.camera.MovieView -d /sdcard/myvideo.mp4 $am start -n com.android.music/com.android.music.MediaPlaybackActivity -d /sdcard/song.mp3
Q: I get this error: ./mkmmc-android.sh: /bin/bash^M: bad interpreter: No such file or directory
Ans:Your mkmmc-android script is in DOS-format. This is perhaps because you originally extracted this file in a Windows PC. This does not work for executable shell scripts in linux. You can convert this to unix-format using the following command:
$ dos2unix mkmmc_android.sh $ chmod a+x mkmmc-android.sh
In case you do not find dos2unix in your ubuntu repositories follow the steps here : http://www.virtualhelp.me/linux/164-dos2unix-missing-ubuntu-1004
Q: How to read contents of boot.scr
Ans: boot.scr is just a set of u-boot commands wrapped within the u-boot uImage executable format. You can easily read the commands embedded in it by directly opening boot.scr in any text editor or by dumping the contents directly on screen as follows:
$ cat boot.scr
You will see only the ASCII contents of the file which is mostly the u-boot commands.
Q: Android Tips to improve user experience
Q: How to switch off android device from console ?
#am start -a android.intent.action.ACTION_REQUEST_SHUTDOWN