This is a quick tip on how to setup Ubuntu to build Android from scrap.
Android / Gingerbread build process itself is pretty straightforward if you follow the standard documentation: http://source.android.com/source/building.html.
What will stop you is that Ubuntu has, in my opinion, two things that annoy every java developer:
a) openjdk / fastjar
b) pulseaudio! Neah, this just annoys everybody :))
This crippled Java kills Gingerbread build process with errors like:
out/target/common/obj/APPS/Camera_intermediates/src/com/android/camera/R.java:10: cannot access java.lang.Object bad class file: java/lang/Object.class(java/lang:Object.class) unable to access file: corrupted zip file Please remove or make sure it appears in the correct subdirectory of the classpath. public final class R { ^
For all the details and the solution here’s how to fix: https://groups.google.com/group/pandaboard/browse_thread/thread/2ad9f0ae099e7db1?fwc=1&pli=1
Correcting the fastjar mess :
sudo update-alternatives --config jar
and selecting the proper Sun / Oracle JDK fastjar alternative.
It now builds correctly in just under one hour! (E8500 / 2Gb DDRAM 800Mhz / RAID-0).
# time make -j8 ... real 59m26.427s user 69m54.414s sys 9m24.187s
So, to get rid of OpenJDK/fastjar, issue the following commands:
apt-get remove icedtea-6-jre-cacao icedtea6-plugin openjdk-6-dbg openjdk-6-demo openjdk-6-doc openjdk-6-jre openjdk-6-jre-headless openjdk-6-jre-lib openjdk-6-source openjdk-6-jre-zero cacao-source default-jdk default-jdk-doc default-jre default-jre-headless
as well as:
apt-get remove fastjar
It will actually remove much more (as there are many dependencies not used), but this does not affect the build process of Gingerbread as long as you have Sun’s JDK installed.
Make sure you check the output and you don’t delete something you need.
Bryan
You sir are nothing short of a saint! THANK YOU!
vidar
hmm, I still have the troubles even when update alternatives for jar and jave only shows suns java after following your steps. So there must be something more missing on myu machine which I do not have a clue what should be