Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Ubuntu 15.04 build Android 5.0 error: You are attempting to build with the incorrect version of java. why?

Tags:

java

android

Error:

============================================
Checking build tools versions...
************************************************************
You are attempting to build with the incorrect version
of java.

Your version is: Picked up JAVA_TOOL_OPTIONS: -javaagent:/usr/share/java/jayatanaag.jar  java version "1.7.0_80" Java(TM) SE Runtime Environment (build 1.7.0_80-b15) Java HotSpot(TM) 64-Bit Server VM (build 24.80-b11, mixed mode).
The required version is: "1.7.x"

Please follow the machine setup instructions at
    https://source.android.com/source/initializing.html
************************************************************
build/core/main.mk:174: *** stop.  Stop.

#### make failed to build some targets (1 seconds) ####

java -version:

$ java -version
Picked up JAVA_TOOL_OPTIONS: -javaagent:/usr/share/java/jayatanaag.jar 
java version "1.7.0_80"
Java(TM) SE Runtime Environment (build 1.7.0_80-b15)
Java HotSpot(TM) 64-Bit Server VM (build 24.80-b11, mixed mode)

javac -version:

$ javac -version
Picked up JAVA_TOOL_OPTIONS: -javaagent:/usr/share/java/jayatanaag.jar 
javac 1.7.0_80


$ 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-7-openjdk-amd64/jre/bin/java   1071      auto mode
  1            /usr/lib/jvm/java-7-openjdk-amd64/jre/bin/java   1071      manual mode
* 2            /usr/lib/jvm/java-7-oracle/jre/bin/java          1         manual mode

$ 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-7-openjdk-amd64/bin/javac   1071      auto mode
  1            /usr/lib/jvm/java-7-openjdk-amd64/bin/javac   1071      manual mode
* 2            /usr/lib/jvm/java-7-oracle/bin/javac          1         manual mode
like image 621
Victor S Avatar asked Sep 27 '22 07:09

Victor S


1 Answers

For those of you that want to build Gingerbread thru KitKat (which requires Oracle JDK 1.6) but already have your system configured for Lollipop (JDK 1.7), here's the easiest way to update your system:

First add the PPA for updated Java builds.

sudo add-apt-repository ppa:webupd8team/java

Then install:

sudo apt-get update && sudo apt-get install oracle-java6-installer

Once that completes, you simply need to tell Linux to use the older version of Java and Java Compiler to render content.

Run the following two commands separately, making the correct selection for Oracle JDK 1.6 both times when prompted. Again in the terminal:

sudo update-alternatives --config java
sudo update-alternatives --config javac
like image 160
BlockchainDeveloper Avatar answered Oct 13 '22 03:10

BlockchainDeveloper