Friday, November 18, 2011

Building Android ICS (ice cream sandwich) with Suse 12.1

The main information for setup and install is best found here: http://source.android.com/source/initializing.html.

That said, there are always build issues since everyone has a slightly different environment.  I am currently running Suse 11.4 that has been upgraded over time from 11.1.  This is all run under a VM in a laptop set for 3/4 GB of RAM available to it on a  3yr old core 2 processor.  Needless to say, it takes a while to build.

There have been several issues that have come up that others may run into.
First, GCC 4.5.0 that comes in 11.3, didn't work.  It came up with an internal compiler error in caller-save.c.  I heard there were issues with 4.6 and that the best compiler for it is probably 4.4.3.  I decided to upgrade to 4.5.1 which comes in 11.4 Suse distro.  This fixed the problem.

3/4GB of RAM is a bit low for doing this build.  I bumped it to 2GB and it didn't have any issues.  I have approximately 20GB of free disk space which seems to be enough.  It takes around 6 or so to do the build.  I used 2G cache size for the build.

Also, make needs to be version 3.81.  Apparently, 3.82 has an bug in it that causes some issues.

The next big issue is with OpenJDK.  There is at least one error:

cts/apps/CtsVerifier/src/com/android/cts/verifier/PassFailButtons.java:191: onCreateDialog(int,android.os.Bundle) in android.app.Activity cannot implement onCreateDialog(int,android.os.Bundle) in com.android.cts.verifier.PassFailButtons.PassFailActivity; attempting to assign weaker access privileges; was public
    private static <T extends android.app.Activity & PassFailActivity>
                    ^
1 error
make: *** [out/target/common/obj/APPS/CtsVerifier_intermediates/classes-full-debug.jar] Error 41

Digging a bit showed that OpenJDK was the problem.  I went and downloaded the Sun JDK which is what is  suggested.  Download info is part of the top installation link.  ICS is built with Java 1.6.  Previously, 1.5 was the required java compiler.  So setting the location of the JDK is important depending on which type of build you want.

Some additional packages are required.  I also did this with a Suse 12.1 64 bit clean install which require even more packages with 4.6.2 as the compiler vs 4.5.1.  The full list is outline below.

bison - used by 'lunch' command
glibc-devel libraries (will see missing gnu-stupbs-32.h)
flex
mesa libraries
zlib devel (32 bit)
ncurses devel (32 bit)
gperf
perl-Switch module
libX11-devel 32 bit

I had the gcc-4.6.2 64 bit version installed.  You'll need to install gcc & gcc-c++ 32bit as well.

Make sure to load the envsetup.sh before the next step: (source build/envsetup.sh).

After installing, setup the path correctly.  For bash, this is:
'export PATH=$PATH;/usr/java/jdk1.6.0_29/bin'
which isn't good enough, had to set the real flag:
'export ANDROID_JAVA_HOME=/usr/java/jdk1.6.0_29'.


In order to get an older revision (the current is 1.7 which won't work), you must signup for an oracle account.

Before you do a make, open development/tools/emulator/opngl/host/renderer/Android.mk.  Double check that it has LOCAL_LDLIBS += -lX11 added.  This fixes a build error that results in 'undefined reference to XInitThreads'.  (Courtesy of Diego Stamigni)

WIth the build 4.0.3 of ICS, there were some build problems using 4.6.2.

- Issue with external/oprofile/libpp/format_output.h, line 94. Change:
mutable count & counts;  to just 'count & counts;'  With latest ics version this has likely been changed.

- ptrdiff_t does not name a type
Add #include <cstddef> in file external/gtest/include/gtest/internal/gtest-param-util.h

- ParamName set but not used
Comment out the line in frameworks/compile/slang/slang_rs_export_foreach.cpp or you can modified the make with -Werror.

Now do a make -j4 and you should be all set.

NOTE: Using Suse 11.4 with gcc 4.5.1, I could build full-magura but there were a number of problems with full-eng.  With Suse 12.1 and gcc 4.6.2, full-eng built without problems.

To run the full-eng emulator, export ANDRIOD_PRODUCT_OUT=~/<android_root>/out/target/product/generic then run the emulator located in out/host/linux-x86/bin/emulator.

Good luck!