Android
Android
Central location for information about the Android port of Gecko.
Current Status
- Full tree builds
- JS builds and shell runs
- xpcshell builds and runs
- Android packaging (apk) works
- application.ini is copied to a file on startup
- components directory is copied on startup
- startup fails on first and sometimes second start
- Android widget draws stuff - http://blog.vlad1.com/2010/02/02/android-progress-more-pixels-edition/
- Keyboard input works
- Softkb works
- Event loop halfway working
- Fennec starts. Some issues with initial sizing. - http://www.flickr.com/photos/madhava_work/4389974241/
Getting Source Code
Currently, the source lives in a user hg repo:
http://hg.mozilla.org/users/vladimir_mozilla.com/mozilla-droid
Work is being done on the "android" branch, so be sure to use:
hg update -C android
to switch to it before building.
Building
Prerequisites
Quickstart (Linux)
Download the SDK and NDK:
wget http://dl.google.com/android/android-sdk_r05-linux_86.tgz wget http://dl.google.com/android/ndk/android-ndk-r3-linux-x86.zip
Then unpack them:
unzip android-ndk-r3-linux-x86.zip tar xvfz android-sdk_r05-linux_86.tgz
The SDK needs to be setup manually.
- In the SDK directory, run tools/android
- Check Settings->Force https://... sources to be fetched using http://...
- Click Save & Apply
- Installed Packages->Update All...
- Select at least the Android SDK, API level 6. Optinally you can install API levels 4 and 7.
- Click Install, Accept, etc.
Building
Full Build
Normal Firefox build, with the following mozconfig. If building fennec, clone the mobile-browser repo as 'mobile' in the toplevel mozilla dir. This assumes that the NDK/SDK were unpacked in the parent directory; if they're elsewhere, change the paths accordingly.
ac_add_options --enable-application=browser ac_add_options --disable-ogg ac_add_options --disable-wave ac_add_options --with-arm-kuser # Global options ac_add_options --enable-debug ac_add_options --disable-optimize # libxul is required ac_add_options --enable-libxul # mobile options ac_add_options --disable-installer ac_add_options --disable-crashreporter ac_add_options --disable-printing ac_add_options --disable-javaxpcom # android options ac_add_options --target=arm-android-eabi ac_add_options --with-android-ndk="$PWD/../android-ndk-r3" ac_add_options --with-android-sdk="$PWD/../android-sdk-linux_86/platforms/android-6" ac_add_options --with-android-tools="$PWD/../android-sdk-linux_86/tools" ac_add_options --with-endian=little ac_add_options --enable-tree-freetype ac_add_options --enable-faststripe # other options ac_add_options --disable-necko-wifi ac_add_options --disable-plugins # ssltunnel can't build because the ndk doesn't have string, vector, or algorithm headers ac_add_options --disable-tests
A standard build should succeed with those paths (note: if you get build bustage in widget, then we're still waiting on a patch that removes the need to poke android internals for gfx).
After that build finishes, a make inside embedding/android should generate a gecko.apk that's installable on an Android device.
JS/NSPR only
In the commands below, replace these with the appropriate paths:
$NDK is the NDK location $moz is the mozilla-droid repo checkout $out is some base destination directory
First, regenerate configure in the js dir (the nspr configure is checked in):
% cd $moz/js/src && autoconf2.13
Then create a nspr directory, configure nspr, and build it:
% cd $out % mkdir nspr % cd nspr % $moz/nsprpub/configure \ --target=arm-android-eabi \ --with-android-ndk=$NDK % make -s
Then do the same for JS, telling it where to find the NSPR you just built:
% cd $out % mkdir js % cd js % $moz/js/src/configure \ --target=arm-android-eabi \ --with-android-ndk=$NDK \ --with-nspr-cflags=-I$out/nspr/dist/include/nspr \ --with-nspr-libs='-L$out/nspr/dist/lib -lnspr4 -lplc4 -lplds4' \ --enable-threadsafe \ --with-endian=little \ --with-arm-kuser % make -s
Running
You'll need to copy the NSPR libraries and the js shell to the emulator or your device. Whether you're running on a physical device or an emulator, /data/local should be writable by the user.
% cd $out/nspr/dist/lib % for f in *.so ; do adb push $f /data/local ; done % cd $out/js/shell % adb push js /data/local
Then, connect to a shell on the device, and run js (adb shell prompts prefixed with "android"):
% adb shell android% cd /data/local android% LD_LIBRARY_PATH=. ./js js> 1+1 2
Debugging with gdb
Preparation
The images included with the SDK for emulation are yaffs2 images and require some work to mount and extract files from. An alternative is to just copy the necessary files from your device via adb pull. /system/bin/linker is referred to by absolute path so setting solib-absolute-prefix in gdb will be necessary for it to be found. Other files can be placed anywhere as long as they can be found in solib-search-path.
In short, find a directory to put some libraries, make sure adb is in your path, and paste this into your terminal:
adb pull /system/bin/linker . && mkdir -p system/bin && mv linker system/bin && for LIB in libc.so libm.so libstdc++.so liblog.so libz.so libGLESv1_CM.so do adb pull /system/lib/$LIB . done
Alternately, unpack the system image of your device somewhere. (eg. signed-dream_devphone_userdebug-ota-14721.zip)
Attach gdb
- Forward a port for gdb between your device and computer using adb. Any port you can open should work. 1234 is used here.
- (Host) adb forward tcp:1234 tcp:1234
- Find the pid of your process if you don't know it
- (Device) ps js
USER PID PPID VSIZE RSS WCHAN PC NAME root 6036 6034 6084 1856 ffffffff afe0c27c T ./js
- Attach gdbserver to the process
- (Device) gdbserver localhost:1234 --attach 6036
Attached; pid = 6036 Listening on port 1234
- Run arm-eabi-gdb on your binary. (android-ndk-1.6_r1/build/prebuilt/linux-x86/arm-eabi-4.2.1/bin)
- (Host) ~/android-ndk-1.6_r1/build/prebuilt/linux-x86/arm-eabi-4.2.1/bin/arm-eabi-gdb js
GNU gdb 6.6 Copyright (C) 2006 Free Software Foundation, Inc. GDB is free software, covered by the GNU General Public License, and you are welcome to change it and/or distribute copies of it under certain conditions. Type "show copying" to see the conditions. There is absolutely no warranty for GDB. Type "show warranty" for details. This GDB was configured as "--host=x86_64-unknown-linux-gnu --target=arm-elf-linux"...
- Configure solib-absolute-prefix. This will point to the directory where you unpacked your system image or where you copied the libraries.
- (Host gdb) set solib-absolute-prefix /home/user/android/sysimg
- Configure solib-search-path. This needs to point to the directories you need debugging symbols from - /system/lib or where ever you copied the libraries.
- (Host gdb) set solib-search-path /home/user/android/sysimg/system/lib:/home/user/android/moz-build/dist/bin
- Connect to gdbserver
- (Host gdb) target remote localhost:1234
Profiling
oprofile is enabled in the kernel on the G1 dev phone and SDK emulator images. The oprofile programs (opcontrol, oprofiled) are in /system/xbin.