Wrong Java Version
I have the Java 6 OpenJDK, version 1.6.0_24. This meets the android Java requirement for 1.6.0, but I found (later in the build process) that Android really needs to be built by Sun’s Java SDK. In the meantime, the _24 suffix doesn’t check out in Android’s makefile, which produces the error You are attempting to build with the incorrect version of java before exiting:
1
2
3
4
5
6
7
8
9
10
11
12
|
Checking build tools versions...
************************************************************
You are attempting to build with the incorrect version
of java.
Your version is: java version "1.6.0_24".
The correct version is: Java SE 1.6.
Please follow the machine setup instructions at
http://source.android.com/source/download.html
************************************************************
build/core/main.mk:131: *** stop. Stop.
|
你可能之前安装过jdk1.6.0_33或其他版本,此时查看jdk 版本,
$ java -version
java version "1.6.0_24"
OpenJDK Runtime Environment (IcedTea6 1.11.5) (6b24-1.11.5-0ubuntu1~12.04.1)
OpenJDK 64-Bit Server VM (build 20.0-b12, mixed mode)
发现版本变成了OpenJDK,下文红色部分可以将更正jdk版本,使编译通过
Installing the Sun Java 6 JDK in Ubuntu 12.04
To fix the make: *** [out/target/common/obj/APPS/CtsVerifier_intermediates/classes-full-debug.jar] Error 41, get the most recent Sun JDK from here. Once you’ve downloaded it, install it and run update-alternatives so your system uses the Sun JDK:
zhoulc@zhoulc-PC:~/work/tools$ sudo mv jdk1.6.0_33/ /usr/lib/jvm/
zhoulc@zhoulc-PC:~/work/tools$ sudo update-alternatives --install /usr/bin/java java /usr/lib/jvm/jdk1.6.0_33/bin/java 1
zhoulc@zhoulc-PC:~/work/tools$ sudo update-alternatives --install /usr/bin/javac javac /usr/lib/jvm/jdk1.6.0_33/bin/javac 1
zhoulc@zhoulc-PC:~/work/tools$ sudo update-alternatives --install /usr/bin/javaws javaws /usr/lib/jvm/jdk1.6.0_33/bin/javaws 1
zhoulc@zhoulc-PC:~/work/tools$ sudo update-alternatives --config java
There are 2 choices for the alternative java (providing /usr/bin/java).
Selection Path Priority Status
------------------------------------------------------------
* 0 /usr/lib/jvm/java-6-openjdk-amd64/jre/bin/java 1061 auto mode
1 /usr/lib/jvm/java-6-openjdk-amd64/jre/bin/java 1061 manual mode
2 /usr/lib/jvm/jdk1.6.0_33/bin/java 1 manual mode
Press enter to keep the current choice[*], or type selection number: 2
update-alternatives: using /usr/lib/jvm/jdk1.6.0_33/bin/java to provide /usr/bin/java (java) in manual mode.
zhoulc@zhoulc-PC:~/work/tools$ sudo update-alternatives --config javac
There are 2 choices for the alternative javac (providing /usr/bin/javac).
Selection Path Priority Status
------------------------------------------------------------
* 0 /usr/lib/jvm/java-6-openjdk-amd64/bin/javac 1061 auto mode
1 /usr/lib/jvm/java-6-openjdk-amd64/bin/javac 1061 manual mode
2 /usr/lib/jvm/jdk1.6.0_33/bin/javac 1 manual mode
Press enter to keep the current choice[*], or type selection number: 2
update-alternatives: using /usr/lib/jvm/jdk1.6.0_33/bin/javac to provide /usr/bin/javac (javac) in manual mode.
zhoulc@zhoulc-PC:~/work/tools$ sudo update-alternatives --config javaws
There are 3 choices for the alternative javaws (providing /usr/bin/javaws).
Selection Path Priority Status
------------------------------------------------------------
* 0 /usr/lib/jvm/java-6-openjdk-amd64/jre/bin/javaws 1061 auto mode
1 /usr/lib/jvm/java-6-openjdk-amd64/jre/bin/javaws 1061 manual mode
2 /usr/lib/jvm/java-7-openjdk-amd64/jre/bin/javaws 1060 manual mode
3 /usr/lib/jvm/jdk1.6.0_33/bin/javaws 1 manual mode
Press enter to keep the current choice[*], or type selection number: 3
update-alternatives: using /usr/lib/jvm/jdk1.6.0_33/bin/javaws to provide /usr/bin/javaws (javaws) in manual mode.
zhoulc@zhoulc-PC:~/work/tools$
To verify that the installation was successful, check Java’s version. It should now show that the Sun JDK is running instead of IcedTea:
java version "1.6.0_33"
Java(TM) SE Runtime Environment (build 1.6.0_33-b04)
Java HotSpot(TM) 64-Bit Server VM (build 20.8-b03, mixed mode)
To revert the changes after Android has been compiled, run update-alternatives to switch back to OpenJDK.