Android

Android is the phone platform released by Google. I currently work at Google and previously worked on the Android team.

Before working for Google, I had been hacking on Android in my spare time since it came out. I created some programs and enhancements for the core of Android:

Development Notes

I work on the Android framework in my spare time. Setting up your development environment is the most tricky part. Here are some notes I collected:

  • function fsnod { mmm -j6 frameworks/base frameworks/base/core/res snod && adb shell stop && adb sync && adb shell start }

    • <romainguy> this will compile only the framework, make the system image, and sync framework.jar onto the device
    • <romainguy> because it also recompiles the resources if necessary
  • adb shell setprop dalvik.vm.dexopt-flags v=n

    • <fadden> Seems to cut the dexopt-ing for core + apps to about 30 seconds

Mac OS X 10.6 Snow Leopard

  • When installing Xcode, you must select the 10.4 SDK compatibility option.
    • Follow the instructions for installing Leopard's Java VM 1.5
    • Load up "Java Preferences" and move "J2SE 5.0 64-bit" to the top.
      • Typing "java -version" should show Java version 1.5.0.
    • Apply patches to projects:
      • git fetch git://android.git.kernel.org/platform/system/core refs/changes/45/11845/4 && git cherry-pick FETCH_HEAD

Debugging Native Code

If you're working on the framework, you're in luck. Debugging native code is pretty easy. Here is how to do it for the emulator. For actual devices, you can forgo the port forwarding and substitute something else in for generic.

I'm assuming you're debugging a Java application which calls out to a native library here. You can also replace app_process with system_server or any other binary.

  1. cd ~/mydroid
  2. lunch (select your target here: generic-eng)
  3. telnet localhost 5554
    1. In telnet, type: redir add tcp:10000:10000
    2. Press CTRL-] and, at the telnet> prompt, type: quit
  4. In another window: adb shell gdbserver 10.0.2.15:10000 --attach [PID of program]
  5. arm-eabi-gdb out/target/product/generic/symbols/system/bin/app_process
  6. In gdb, type: set solib-search-path out/target/product/generic/symbols/system/lib:out/target/product/generic/symbols/system/bin
  7. In gdb, type: target remote localhost:10000

Kenny Root

Copyright © Kenny Root. All rights reserved.