Android Gingerbread on Linux Mint 14 Nadia (Ubuntu 12.10) – NOTES

 

System:
Linux Mint 14 64-bit Cinnamon (Ubuntu 12.10 based)
Full update as of 1 Dec 2012
GCC 4.7.2
Followed the directions in (http://source.android.com/source/initializing.html) and installed the packages
$ sudo apt-get install git-core gnupg flex bison gperf dpkg-dev gcc-multilib build-essential   zip curl libc6-dev libncurses5-dev:i386 x11proto-core-dev   libx11-dev:i386 libreadline6-dev:i386 libgl1-mesa-glx:i386   libgl1-mesa-dev g++-multilib mingw32 openjdk-6-jdk tofrodos   python-markdown libxml2-utils xsltproc zlib1g-dev:i386

Note the addition of dpkg-dev and gcc-multilib. If you don’t add them then you get a dependency error

Then went into the target directory to get the source as directed (http://source.android.com/source/downloading.html). Since we are using Gingerbread we used the -b option
$ repo init -u https://android.googlesource.com/platform/manifest -b gingerbread
After a long break (it took me >2 hours to get the source), start to compile the source
$ source build/envsetup.sh

$ lunch full-eng

$ make -j8 #first attempt

This won’t compile because of the Java Version warning. We will now try to disable the Java version check, but it doesn’t work.

Edit the file build/core/main.mk to remove the warning
Line 118: $(error stop)

(DID NOT WORK) – in hindsight this might be related to the make_names.pl error below
Unknown parameter a interfaceName for tags/attrs
make: *** [out/target/product/generic/obj/STATIC_LIBRARIES/libwebcore_intermediates/WebCore/HTMLElementFactory.h] Error 255
make: *** Waiting for unfinished jobs….
Unknown parameter a interfaceName for tags/attrs
Unknown parameter a interfaceName for tags/attrs
make: *** [out/target/product/generic/obj/STATIC_LIBRARIES/libwebcore_intermediates/WebCore/V8HTMLElementWrapperFactory.h] Error 255
make: *** [out/target/product/generic/obj/STATIC_LIBRARIES/libwebcore_intermediates/WebCore/HTMLNames.cpp] Error 255
Unknown parameter base for tags/attrs
make: *** [out/target/product/generic/obj/STATIC_LIBRARIES/libwebcore_intermediates/WebCore/XMLNames.cpp] Error 255
Unknown parameter a interfaceName for tags/attrs
Unknown parameter xmlns for tags/attrs
make: *** [out/target/product/generic/obj/STATIC_LIBRARIES/libwebcore_intermediates/WebCore/XMLNSNames.cpp] Error 255
make: *** [out/target/product/generic/obj/STATIC_LIBRARIES/libwebcore_intermediates/WebCore/HTMLNames.h] Error 255
Unknown parameter a interfaceName for tags/attrs
make: *** [out/target/product/generic/obj/STATIC_LIBRARIES/libwebcore_intermediates/WebCore/V8HTMLElementWrapperFactory.cpp] Error 255
Unknown parameter a interfaceName for tags/attrs
make: *** [out/target/product/generic/obj/STATIC_LIBRARIES/libwebcore_intermediates/WebCore/HTMLElementFactory.cpp] Error 255

As a result we try to use openjdk1.6 instead

$ update-java-alternatives -l # to list the alternatives
$ update-java-alternatives -s /usr/lib/jvm/java-1.6.0-openjdk-amd64 #I get a couple of errors about jcmp and some IceTea library for mozilla

Now we try to build again and get an error with ld -lz (so we install libz)

$ sudo apt-get install libz-dev #note they change this to zlib1g-dev automatically

Yet another error:
host C++: aapt <= frameworks/base/tools/aapt/AaptAssets.cpp
<command-line>:0:0: warning: “_FORTIFY_SOURCE” redefined [enabled by default]
frameworks/base/tools/aapt/AaptAssets.cpp:1:0: note: this is the location of the previous definition
In file included from frameworks/base/tools/aapt/AaptAssets.h:18:0,
from frameworks/base/tools/aapt/AaptAssets.cpp:5:
frameworks/base/tools/aapt/ZipFile.h:65:5: warning: ‘typedef’ was ignored in this declaration [enabled by default]
In file included from frameworks/base/include/utils/AssetManager.h:25:0,
from frameworks/base/tools/aapt/AaptAssets.h:10,
from frameworks/base/tools/aapt/AaptAssets.cpp:5:
frameworks/base/include/utils/KeyedVector.h: In instantiation of ‘const VALUE& android::DefaultKeyedVector<KEY, VALUE>::valueFor(const KEY&) const [with KEY = #android::String8; VALUE = android::sp<AaptSymbols>]’:
frameworks/base/tools/aapt/AaptAssets.h:419:59:   required from here
frameworks/base/include/utils/KeyedVector.h:193:31: error: ‘indexOfKey’ was not declared in this scope, and no declarations were found by argument-dependent lookup at the #point of instantiation [-fpermissive]
frameworks/base/include/utils/KeyedVector.h:193:31: note: declarations in dependent base ‘android::KeyedVector<android::String8, android::sp<AaptSymbols> >’ are not found #by unqualified lookup
frameworks/base/include/utils/KeyedVector.h:193:31: note: use ‘this->indexOfKey’ instead
frameworks/base/include/utils/KeyedVector.h: In instantiation of ‘const VALUE& android::DefaultKeyedVector<KEY, VALUE>::valueFor(const KEY&) const [with KEY = #android::String8; VALUE = android::sp<AaptGroup>]’:
frameworks/base/tools/aapt/AaptAssets.cpp:1388:41:   required from here
frameworks/base/include/utils/KeyedVector.h:193:31: error: ‘indexOfKey’ was not declared in this scope, and no declarations were found by argument-dependent lookup at the #point of instantiation [-fpermissive]
frameworks/base/include/utils/KeyedVector.h:193:31: note: declarations in dependent base ‘android::KeyedVector<android::String8, android::sp<AaptGroup> >’ are not found by #unqualified lookup
frameworks/base/include/utils/KeyedVector.h:193:31: note: use ‘this->indexOfKey’ instead
frameworks/base/include/utils/KeyedVector.h: In instantiation of ‘const VALUE& android::DefaultKeyedVector<KEY, VALUE>::valueFor(const KEY&) const [with KEY = #android::String8; VALUE = android::sp<AaptDir>]’:
frameworks/base/tools/aapt/AaptAssets.cpp:1447:53:   required from here
frameworks/base/include/utils/KeyedVector.h:193:31: error: ‘indexOfKey’ was not declared in this scope, and no declarations were found by argument-dependent lookup at the #point of instantiation [-fpermissive]
frameworks/base/include/utils/KeyedVector.h:193:31: note: declarations in dependent base ‘android::KeyedVector<android::String8, android::sp<AaptDir> >’ are not found by #unqualified lookup
frameworks/base/include/utils/KeyedVector.h:193:31: note: use ‘this->indexOfKey’ instead
make: *** [out/host/linux-x86/obj/EXECUTABLES/aapt_intermediates/AaptAssets.o] Error 1

Turns out this is related to the following errors in building ICS with some patches (https://groups.google.com/forum/?fromgroups=#!topic/android-building/2EwtWQTqjdI)
– ARG GCC 4.7 made some fixes and its a good thing but still arg. Underlying problem seems to be that the old code did not follow the C++ standard and since older versions of GCC (prior to 4.6?) did not enforce them these were never reported. Since they are enforced now, we need to add the -permissive flag or fix the code to make the newer version of GCC happy.
Fix 1 – it is on Line 28 in gingerbread – same file. That is add the -fpermissive flag to GCC in frameworks/base/tools/aapt/Android.mk
Fix 2 is on line 60 – same -fpermissive flag in frameworks/base/libs/utils/Android.mk

Fix 3 is applied as the patch states – Please take a look at the patch though because the same kind of fix is needed later (and is not part of the list). Essentially, the patch inserts “this->” in front of a bunch of function calls.

Fix 4 is applied – I inserted the include after stdlib.h on line 17 in development/tools/emulator/opengl/host/tools/emugen/main.cpp
17: #include <stdlib.h>
18: #include <getopt.h>
Did not apply Fix 5
Fix 6 is applied without changes, that is added -fpermissive to line 25 in development/tools/emulator/opengl/Android.mk
Next I received a bunch of errors from external/v8/src which are related to the errors from Fix 3. The error looks something like:
external/v8/src/objects.h:2133:5: error: ‘set’ was not declared in this scope, and no declarations were found by argument-dependent lookup at the point of instantiation [-fpermissive]
external/v8/src/objects.h:2133:5: note: declarations in dependent base ‘v8::internal::FixedArray’ are not found by unqualified lookup
external/v8/src/objets.h:2133:5: note: use ‘this->set’ instead
Essentially I went into external/v8/src/v8.h and external/v8/src/objects.cc and external/v8/src/objects.h and fixed the problematic calls by prepending a this-> in front of them.
For example FindEntry is changed to this->FindEntry in external/v8/src/objects.cc
Then I got the error for “memcpy” that looks like:
external/v8/src/globals.h:605:3: error: ‘memcpy’ was not declared in this scope, and no declarations were found by argument-dependent lookup at the point of instantiation –fpermissive]
This error can be fixed by including <string.h> which I did by including it in v8.h (which is included by others)
Under // basic includes
54: // Basic Includes
55: #include <string.h>
56: #include “../include/v8.h”
After these fixes the next error looked like:
host C++: obbtool <= frameworks/base/tools/obbtool/Main.cpp
<command-line>:0:0: error: “_FORTIFY_SOURCE” redefined [-Werror]
This error is related to Fix 8 and the fix is similar – remove -Werror from frameworks/base/tools/obbtool/Android.mk on line 16:
LOCAL_CFLAGS := -Wall -Werror
After this change, the next error is a complaint about missing -lGL from ld.
This is fixed by creating a new link. If you try sudo apt-get install libgl-dev (it will revert to libg1-mesa) but will state that it is already installed because we did it at the beginning. So the only thing left to do is make sure that either libGL is in your library path – or just create a new link from /usr/lib such as
$ sudo ln -s /usr/lib/i386-linux-gnu/mesa/libGL.so.1 /usr/lib/libGL.so
That should fix this problem.
After this then we get another set of errors that are related to -Werror with the same fix. The location is in frameworks/base/tools/obbtool/Android.mk on line 37 (yes this is the same file as above – apparently the same make file is used for two packages?)
If we try to build this then there will be a problem with OpenJDK something that looks like:
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>
So we will try to install the Sun java 1.6 instead

downloaded the oracle/sun java version (1.6.0 update 37 for me)

Unzipped it by running the script
This should create the jdk1.6.0_37 directory
To use this particular version of Java, we can either do some update-java-alternatives magic (which I tried but failed horribly - my copy of .jinfo didn’t work – returned errors about the alternatives not having been registered) or follow the comments from thesoftwarerogue.blogspot.com and just change the path.
$ export PATH=~/Downloads/jdk1.6.0_37/bin:$PATH
After that then just do a make (after a make clean of course — apparently this is not needed – neat) and everything should build – except for some strange error in a pl file that looks like:
Unknown parameter a interfaceName for tags/attrs
To fix, you need to remove the -P flag from $preprocessor in external/webkit/WebCore/dom/make_names.pl (see http://code.google.com/p/chromium/issues/detail?id=46411)
Everything builds, except not everything works yet. If you tried to run the Android emulator using the new android image and the pre-built kernel you will first get the following error:
$ cd out/host/linux-x86/bin
$ ./emulator -sysdir ../../../target/product/generic/ -kernel ../../../../prebuilt/android-arm/kernel/kernel-qemu-armv7
emulator: ERROR: You did not provide the name of an Android Virtual Device with the ‘-avd <name>’ option. Read -help-avd for more information.
If you *really* want to *NOT* run an AVD, consider using ‘-data <file>’ to specify a data partition image file (I hope you know what you’re doing).
The problem is that the emulator is really meant to run AVDs with certain environment variables set and not for the way I am using it. So the first thing you have to do is to create a new user image (i.e. disk image used to store the temporary user information). To do this just touch the file, the emulator is helpful enough to do the resizing and anything else for you.
$ touch ../../../target/product/generic/userdata-qemu.img
After this, running the same emulator command as above will show a blinking android….. but it won’t go anywhere. As it turns out the problem is with the qemu version included in the gingerbread branch (http://source.android.com/source/known-issues.html)
From that site, you can see the entry for Black Gingerbread Emulator follow those directions
First update to a newer version from the parent android gingerbread directory
$ repo forall platform/external/qemu -c git checkout aosp/tools_r12
(I didn’t see any real output or activity except some message about an updated HEAD. The best way to see if the code was updated for me was to see if the files were updated by doing a ls -ltr on the external/qemu directory)
Do a make clean and another make and then follow the same instructions for a good build.
Finally!

 

 

Posted in Uncategorized

Leave a Reply

Your email address will not be published. Required fields are marked *

*

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>