最近因为需要编译android 4.1.2,在os x 10.8.3 用 Xcode 4.5的环境编译。因为之前,顺利的编译过Android 4.2.2 (JDQ39). for Nexus 7 (Wi-Fi) ("grouper"). 也就继续在这个环境下开始编译Android 4.1.2 ( JZO54K),但过程并不顺利,遇到了些错误,也纪录下来,供其他人参考。
最终我还是参考google官方的资料(http://source.android.com/source/initializing.html),在Os x中用virtualbox安装ubuntu 10.04 LTS 完成了对4.1.2的编译。成功标志是,在输出目录out/target/product/grouper下生成的 img文件。
/Volumes/android/out/target/product/grouper
johnsontekiMacBook-Pro:grouper johnson$ ls
android-info.txt ramdisk.img
boot.img recovery
clean_steps.mk recovery.img
data root
installed-files.txt symbols
kernel system
obj system.img
previous_build_config.mk test
ramdisk-recovery.img userdata.img
下载时,使用:https://groups.google.com/forum/?fromgroups=#!topic/android-building/2rkEoKMnhzU
The build number is JZO54K, and the tag isandroid-4.1.2_r1.
最有价值的参考见我转的博文:
http://blog.csdn.net/dull_boy2/article/details/8977890
其中,JDK安装参考了如下链接:
http://www.wikihow.com/Install-Oracle-Java-JDK-on-Ubuntu-Linux
先要去掉OPENJDK,如上文中第二、三步所述。
Check if you have Java installed on your system
java-version
OpenJDK Runtime Environment (IcedTea6 1.10pre) (7b15~pre1-0lucid1)
OpenJDK 64-Bit Server VM (build 19.0-b09, mixed mode)
sudo apt-get purge openjdk-\*
https://help.ubuntu.com/community/Java#Oracle_.28Sun.29_Java_6
$ wget --no-cookies --header "Cookie: gpw_e24=http%3A%2F%2Fwww.oracle.com%2F" http://download.oracle.com/otn-pub/java/jdk/6u45-b06/jdk-6u45-linux-x64.bin $ chmod u+x jdk-6u45-linux-x64.bin $ ./jdk-6u45-linux-x64.bin $ sudo mv jdk1.6.0_45 /opt $ sudo update-alternatives --install "/usr/bin/java" "java" "/opt/jdk1.6.0_45/bin/java" 1 $ sudo update-alternatives --install "/usr/bin/javac" "javac" "/opt/jdk1.6.0_45/bin/javac" 1 $ sudo update-alternatives --install "/usr/lib/mozilla/plugins/libjavaplugin.so" "mozilla-javaplugin.so" "/opt/jdk1.6.0_45/jre/lib/amd64/libnpjp2.so" 1 $ sudo update-alternatives --install "/usr/bin/javaws" "javaws" "/opt/jdk1.6.0_45/bin/javaws"
IMPORTANT choose the java you installed as default
$ sudo update-alternatives --config java $ sudo update-alternatives --config javac $ sudo update-alternatives --config mozilla-javaplugin.so $ sudo update-alternatives --config javaws
Optionally you can set a JAVA_HOME env variable:
export _JAVA_HOME=/opt/jdk1.6.0_45/
If your system has more than one version of Java, configure which one your system uses by entering the following command in a terminal window
sudo update-alternatives --config java
This will present you with a selection that looks similar to the following (the details may differ for you):
There are 2 choices for the alternative java (providing /usr/bin/java). Selection Path Priority Status ———————————————————— * 0 /usr/lib/jvm/java-6-openjdk/jre/bin/java 1061 auto mode 1 /usr/lib/jvm/jre1.7.0/jre/bin/java 3 manual mode Press enter to keep the current choice[*], or type selection number: 1
ALL DONE. You can test your java install by
java -version
Here is a small screen capture of what happened on my screen when I went through above steps
Finally if you need to add JAVA_HOME variable, you can do so by adding it to the .bashrc file in your home directory
Open .bashrc file using an editor. If you use VI then
vi ~/.bashrc
and add the following 2 lines in your .bashrc file.
JAVA_HOME=/usr/lib/jvm/jdk1.7.0_21/
export JAVA_HOME
There may be other ways to install, but this is what I have followed always.
参考:http://blog.manishchhabra.com/2012/05/installing-oracle-sun-java-jdk-and-setting-java_home-in-ubuntu-linux/
http://www.ubuntuhome.com/ubuntu10-04-jdk.html
这个也是不错的参考:
Android Hacking Guide2
https://docs.google.com/document/d/1eyM3PnaF4XDsYaRBiQ9pUxYRnrWxFvkHBYHVomwzer8/edit?pli=1
在os x 10.8.3 用 Xcode 4.5的环境编译下,出现的一些错误:
1. make: *** [out/host/darwin-x86/obj/lib/libSR_Recognizer.dylib] Error 1
2,external/elfutils/libelf/elf_begin.c:1025:23: error: expected ';' at end of declaration