Android: Difference between revisions

5,301 bytes removed ,  4 May 2010
(→‎Building: Add section about fixing headers)
 
(39 intermediate revisions by 6 users not shown)
Line 1: Line 1:
= Android =
#redirect [[Mobile/Fennec/Android]]
 
Central location for information about the Android port of Gecko.
 
== Current Status ==
 
* Full tree builds
** NO NSS support (needs NSS build system hacking)
* JS builds and shell runs
* xpcshell builds and 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 ===
 
* Standard [https://developer.mozilla.org/En/Linux_Build_Prerequisites Linux build environment], at least as far as tools like gnu make, gcc, and autoconf2.13 go
* [http://developer.android.com/sdk/ndk/1.6_r1/index.html Android 1.6 NDK]
 
The NDK is the only Android-specific prereq for building, though you will probably want the [http://developer.android.com/sdk/ Android SDK] for an emulator and tools such as 'adb'.  Either 2.0 or 1.6 will do.
 
==== Quickstart (Linux) ====
Just paste these commands into your terminal to download and install the NDK and SDK.
 
# get SDK and NDK
wget http://dl.google.com/android/android-sdk_r04-linux_86.tgz &&
wget http://dl.google.com/android/ndk/android-ndk-1.6_r1-linux-x86.zip &&
# unpack SDK and NDK
unzip android-ndk-1.6_r1-linux-x86.zip &&
tar xvfz android-sdk_r04-linux_86.tgz &&
# setup NDK
cd android-ndk-1.6_r1 &&
build/host-setup.sh &&
cd ..
 
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...
* You may uncheck everything you don't need. Just installing the latest 1.x and 2.x SDKs is fine.
* Click Install Accepted
 
=== Building ===
 
==== Fix headers ====
 
Certain header files in the NDK do not compile as C++. Paste this command in your terminal while in the NDK directory to patch them.
 
patch -p1 << "EOF"
--- tmp/android-ndk-1.6_r1/build/platforms/android-4/arch-arm/usr/include/asm-generic/siginfo.h  2009-07-28 17:26:01.000000000 -0700
+++ android-ndk-1.6_r1/build/platforms/android-4/arch-arm/usr/include/asm-generic/siginfo.h      2009-12-09 11:48:46.000000000 -0800
@@ -55,7 +55,7 @@
  struct {
  timer_t _tid;
  int _overrun;
- char _pad[sizeof( __ARCH_SI_UID_T) - sizeof(int)];
+ //char _pad[sizeof( __ARCH_SI_UID_T) - sizeof(int)];
  sigval_t _sigval;
  int _sys_private;
  } _timer;
--- tmp/android-ndk-1.6_r1/build/platforms/android-4/arch-arm/usr/include/dlfcn.h 2009-07-28 17:26:01.000000000 -0700
+++ android-ndk-1.6_r1/build/platforms/android-4/arch-arm/usr/include/dlfcn.h    2009-12-09 11:51:20.000000000 -0800
@@ -42,7 +42,7 @@
    RTLD_LAZY = 1,
    RTLD_LOCAL  = 0,
-  RTLD_GLOBAL = 2,
+  RTLD_GLOBAL = 2
  };
  #define RTLD_DEFAULT  ((void*) 0xffffffff)
EOF
 
==== 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
 
= Other Resources =
 
* [https://wiki.mozilla.org/User:Joel_Reymont/Android_Notes Joel's Notes]
* [https://wiki.mozilla.org/User:VladVukicevic/Android_Notes Vlad's Notes]
* [http://hg.mozilla.org/users/vladimir_mozilla.com/android-testapp/ Vlad's Test App Hg Repo]
canmove, Confirmed users
1,584

edits