NOTICE: The Processors Wiki will End-of-Life on January 15, 2021. It is recommended to download any files or other content you may need that are hosted on processors.wiki.ti.com. The site is now set to read only.

Android Developer FAQs

From Texas Instruments Wiki
Jump to: navigation, search

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.

Contents

Booting[edit]

Q: While booting, kernel boots fine but problem comes when actual Android processes start.Following logs appears on the screen.[edit]

"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])


Android System[edit]

Q: init.rc tutorial. Android initialization process[edit]

Ans:http://blog.csdn.net/loughsky/article/details/3293922

Q: How to port an Android on ARM based SoC?[edit]

Ans:http://blogs.arm.com/software-enablement/498-from-zero-to-boot-porting-android-to-your-arm-platform/

Q: Where to add custom property in Android?[edit]

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 ?[edit]

Ans: : Very good explain given by rxwen at
http://rxwen.blogspot.com/2010/01/android-property-system.html

Q: How to create custom service in Android ?[edit]

Ans: : Wiki guide & few references are mentioned below
http://processors.wiki.ti.com/index.php/Android-Adding_SystemService
http://developerlife.com/tutorials/?p=356
http://mylifewithandroid.blogspot.com/2008/02/double-life-of-service.html
http://marakana.com/forums/android/examples/60.html

Q:logcat is not working. Command "ls /sys/kernel/logger" return error. What is the catch?[edit]

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?[edit]


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 ?[edit]

Ans: : http://discuz-android.blogspot.com/2008/01/set-proxy-for-android-web-browser.html

Q: How does touchscreen or keyboard event process in android ? Input event handling in android[edit]

Ans: : http://cjix.info/blog/misc/internal-input-event-handling-in-the-linux-kernel-and-the-android-userspace/

Q: How to see apk contents ?[edit]

Ans: : jar -tvf <apk-name>.apk

Q: How to change android start language ?[edit]

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 ?[edit]

Ans: : Refer to the project #http://code.google.com/p/android-serialport-api/wiki/Building_the_project android-serialport-api

Memory[edit]

Q:How to do auto mount sdcard ?[edit]

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 ?[edit]

TBD

Q:Where to locate prelink android libraries ?[edit]

Ans: : Refer "build/core/prelink-linux-arm.map" file

Q: How to use generic audio ?[edit]

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[edit]

Q: How to debug android crash?[edit]

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 */ 

Other references for debugging:
http://kobablog.wordpress.com/2011/05/14/how-to-read-crash-dump-of-android/
http://kobablog.wordpress.com/2011/05/12/debuggerd-of-android/


Peripherals[edit]

TI porting guide available at

http://processors.wiki.ti.com/index.php/TI-Android-GingerBread-2.3.4-DevKit-2.1_PortingGuides

Q: How to port wifi driver to Android device?[edit]

Ans: : Kindly refer 'Porting WiFi drivers to Android'

  1. http://processors.wiki.ti.com/index.php/TI-Android-GingerBread-2.3.4-DevKit-2.1_PortingGuides#WLan
  2. http://blog.linuxconsulting.ro/2010/04/porting-wifi-drivers-to-android.html
  3. http://www.slatedroid.com/topic/16962-posible-solution-to-wifi-problems
  4. Most common mistake while porting wifi device :

http://e2e.ti.com/support/embedded/f/509/p/123347/495316.aspx#495316

Q: How to configure keypad on Android device?[edit]

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 ?[edit]

Ans: : The GPIO keypad driver example is at
http://lxr.free-electrons.com/source/drivers/input/keyboard/gpio_keys.c
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
  1. where key is common key word
  2. where 256 is decimal equivalent of the value obtained through getevent
  3. where MENU is Android key Code
  4. 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 ?[edit]

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.

Example->

add  the line ueventd.<yourboard>.rc file  
/dev/video0         0666  root       root 
  1. where /dev/video0 is node
  2. where 0666 is premission
  3. where root is system
  4. where root is radio

Q: How to get USB stick installed ? How to install apk residing on USB stick ?[edit]

Ans: :
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 ?[edit]

LCD:
http://processors.wiki.ti.com/index.php/TI-Android-GingerBread-2.3.4-DevKit-2.1_PortingGuides#Display
Touchscreen:
http://processors.wiki.ti.com/index.php/TI-Android-GingerBread-2.3.4-DevKit-2.1_PortingGuides#Touchscreen

Q:How to add or port radio layer interface on android ?[edit]

Ans: :
http://afewe.wordpress.com/android-arm-development/working-with-the-radio-layer-interface-ril-in-android/

Q:How to add ethernet support in settings for android gingerbread ?[edit]

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 ?[edit]

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[edit]

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 Errors[edit]

Build error on 64-bit machine[edit]

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

Error:[edit]

[out/target/common/obj/APPS/BluetoothSCOApp_intermediates/classes-full-debu­g.jar] 
Error 41 
make: *** Waiting for unfinished jobs.... 
out/target/common/obj/APPS/Calculator_intermediates/src/com/android/calcula­tor2/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.

Error:[edit]

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

Ans:run

$sudo apt-get install libc6-dev-i386

Error: cannot stat pvrsrvkm.ko[edit]

cp: cannot stat `android/hardware/ti/sgx/eurasiacon/binary2_omap4430_android_release/target/pvrsrvkm.ko': No such file or directory
make[1]: *** [buildkernel] Error 1
make[1]: 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 <umakanta.patro@ti.com>
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 <hedwin.koning@gmail.com>
Signed-off-by: Umakanta Patro <umakanta.patro@ti.com>
---
 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
-- 
1.7.9.5

Others[edit]

Q:How to start android application from command line or console ?[edit]

Ans:

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 ?[edit]

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 <vishveshwar.bhat@ti.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:Any link for getting started on porting android for new mobile device ?[edit]

Ans: http://www.kandroid.org/android_pdk/build_new_device.html

Q: How to use mplayer command to play the camera video?[edit]

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?[edit]

Ans:

$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[edit]

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[edit]

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[edit]

Ans: http://gailly.net/android/android-tips.html

Q: How to switch off android device from console ?[edit]

Ans:

#am start -a android.intent.action.ACTION_REQUEST_SHUTDOWN

Benchmark[edit]


References[edit]

http://dotdot.itg.ti.com/scuttle/search.php/all/android
http://androidzaurus.seesaa.net/ : boot chart
http://www.butterscotch.com/tutorial/How-To-Change-The-Desktop-Interface-On-Your-Android-Phone

E2e.jpg {{
  1. switchcategory:MultiCore=
  • For technical support on MultiCore devices, please post your questions in the C6000 MultiCore Forum
  • For questions related to the BIOS MultiCore SDK (MCSDK), please use the BIOS Forum

Please post only comments related to the article Android Developer FAQs here.

Keystone=
  • For technical support on MultiCore devices, please post your questions in the C6000 MultiCore Forum
  • For questions related to the BIOS MultiCore SDK (MCSDK), please use the BIOS Forum

Please post only comments related to the article Android Developer FAQs here.

C2000=For technical support on the C2000 please post your questions on The C2000 Forum. Please post only comments about the article Android Developer FAQs here. DaVinci=For technical support on DaVincoplease post your questions on The DaVinci Forum. Please post only comments about the article Android Developer FAQs here. MSP430=For technical support on MSP430 please post your questions on The MSP430 Forum. Please post only comments about the article Android Developer FAQs here. OMAP35x=For technical support on OMAP please post your questions on The OMAP Forum. Please post only comments about the article Android Developer FAQs here. OMAPL1=For technical support on OMAP please post your questions on The OMAP Forum. Please post only comments about the article Android Developer FAQs here. MAVRK=For technical support on MAVRK please post your questions on The MAVRK Toolbox Forum. Please post only comments about the article Android Developer FAQs here. For technical support please post your questions at http://e2e.ti.com. Please post only comments about the article Android Developer FAQs here.

}}

Hyperlink blue.png Links

Amplifiers & Linear
Audio
Broadband RF/IF & Digital Radio
Clocks & Timers
Data Converters

DLP & MEMS
High-Reliability
Interface
Logic
Power Management

Processors

Switches & Multiplexers
Temperature Sensors & Control ICs
Wireless Connectivity