Android

From MozillaWiki
Jump to navigation Jump to search

Android

Central location for information about the Android port of Gecko.

Current Status

  • NSPR builds
  • JS builds and shell runs

Getting Source Code

Currently, the source lives in a user hg repo:

http://hg.mozilla.org/users/vladimir_mozilla.com/mozilla-droid

Building

Prerequisites

The NDK is the only Android-specific prereq for building, though you will probably want the Android SDK for an emulator and tools such as 'adb'. Either 2.0 or 1.6 will do.

Building

Full Build

Normal build, with the following mozconfig:

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

# 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=/home/vladimir/proj/android/android-ndk-1.6_r1
ac_add_options --with-endian=little
ac_add_options --enable-tree-freetype

# other options
ac_add_options --disable-necko-wifi
ac_add_options --disable-plugins

# to fix
ac_add_options --disable-crypto
# ssltunnel can't build if we disable crypto
ac_add_options --disable-tests

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