Thursday, January 20, 2011

Android debug tips(shell)


Here's a set of a few Android debugging tips. I've found them quite helpful.
 
1. You've installed an APK and want to know its package name, i.e. mapping APK to the package name.
    $ adb shell
    # pm list packages -f
 
2. Try to mount rw the data/system partition of a dev phone.
    $ adb remount
3. Sync the device after any pull/push operation.
    $ adb shell sync
 
4. Manually start an activity.
    $ adb shell
    # am -D <intent>
 
5. Manually start an activity with package and activity name.
    $ adb shell
    # am start -a <action> -n <package name>/<activity name>
 
6. Manually send a broadcast.   
    $ adb shell
    # am broadcast <intent> 
 
7. View/Change Kernel params of an android phone.
    $ adb shell
    # getprop
    # setprop <key> <value>
 
8. Search a package on the Android Market,
    market://search?q=pname:<package_name>
 
9. View an APK's content:
    $ aapt l <apk>
 
10. View an APK's Manifest file:
       
    Get Manifest main info.
    $ aapt d badging <APK>

11. dexdump - Dissembling the classes.dex.
    Extract the APK or if its installed find it from here and do adb pull for classes.dex,
    $ adb shell
    # cd /data/dalvik-cache
    # ls
-rw-rw-rw- root root 73852 2007-11-27 05:16 system@app@Contacts.apk@classes.dex
-rw-rw-rw- app_0 app_0 64172 2007-11-27 05:17 system@app@ContactsProvider.apk@classes.dex
 
    $ dexdump classes.dex -d -f -h [-l xml/plain] >> classes.dexdump
Here's an example of xml dexdump.
<class name="MyClass"extends="com.abc.xyz.Parent"abstract="false"static="false"final="false"visibility="public"><constructor name="MyClass"type="com.abc.xyz.MyClass"static="false"final="false"visibility="public"></constructor><method name="invalidateView"return="void"abstract="false"native="false"synchronized="false"static="false"final="false"visibility="public">

No comments:

Post a Comment