Hi! When building Android Open Source Project (AOSP) it is required to have the correct version of java specified in the main.mk file. Otherwise, you will get different errors as follows as specified in the main make file. For example, AOSP for android version 6.0.1 required java 1.7 and android version 7.1.2 requires java 1.8. Sometimes it requires the openjdk version instead oracle java version.
Possible Errors:
1. ************************************************************ You are attempting to build with the incorrect version Your version is: "1.8.0_171" The required version is: "1.7" ************************************************************ 2. Checking build tools versions... ************************************************************ You asked for an OpenJDK 7 build but your version is 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). ************************************************************ 3. ************************************************************ You are attempting to build with the incorrect version of javac. Your version is: javac 1.8.0_171. The required version is: "1.7" Please follow the machine setup instructions at https://source.android.com/source/download.html ************************************************************
However, the java 1.7 jdk cannot install via sudo apt-get install on kali. Therefore, you can download the tar.gz version from oracle website and manually installed via following commands.
Solution:
-
cd jdk1.7.0_80
-
update-alternatives --install /usr/bin/java java /home/Java/jdk1.7.0_80/bin/java 100
-
update-alternatives --install /usr/bin/javac javac /home/Java/jdk1.7.0_80/bin/javac 100
-
update-alternatives --config java
-
update-alternatives --config javac
If you do not have openjdk 7 but have java jdk 7 then you can avoid the build stop by commenting “$(error stop)” as below.
Note*: Remove unnecessary installations using following command
-
update-alternatives --remove java /home/Java/jdk1.7.0_80/bin/java
Cheers! 🙂
Follow Android documentation for building Aosp to avoid unnecessary hassle.
https://source.android.com/setup/build/building
LikeLike