Issue
I'm building an Ionic Cordova cross platform app. When i run ionic cordova build android I get the following error.
cordova-android-support-gradle-release: Android platform: V7+
cordova-plugin-androidx-adapter: Processed 65 source files in 1452ms
Checking Java JDK and Android SDK versions
ANDROID_SDK_ROOT=undefined (recommended setting)
ANDROID_HOME=/Users/anonymous/Library/Android/sdk (DEPRECATED)
Requirements check failed for JDK 8 ('1.8.*')! Detected version: 15.0.1
Check your ANDROID_SDK_ROOT / JAVA_HOME / PATH environment variables.
[ERROR] An error occurred while running subprocess cordova.
Here is my java version:
java version "15.0.1" 2020-10-20 Java(TM) SE Runtime Environment (build 15.0.1+9-18) Java HotSpot(TM) 64-Bit Server VM (build 15.0.1+9-18, mixed mode, sharing)
Everything was working until I downloaded the latest Java SDK, now I can't build Android.
I read in another Stack post that this is bad: java version "15.0.1" 2020-10-20 Java(TM) SE Runtime Environment (build 15.0.1+9-18) Java HotSpot(TM) 64-Bit Server VM (build 15.0.1+9-18, mixed mode, sharing)
I'm not really sure how to resolve this and why the Java SDK doesn't appear when I check Java -version.
I set this in my .bash_profile ANDROID_HOME=/Users/anonymous/Library/Android/sdk ANDROID_SDK_ROOT=~/Library/Android/sdk
Solution
Android fully supports java 7 and a subset of java 8 and 9 features. So, yes, the JDK 15 you downloaded is not compatible with the Android development platform.
AdoptOpenJDK 1.8 is the preferred JDK for Android development (don't quote me on this, there may be disagreements)
Then, from the build log you can see ANDROID_SDK_ROOT=undefined (recommended setting)
. That's fine, ANDROID_SDK_ROOT
can be undefined.
After you've downloaded the correct JDK, the only two environment you need to set are:
export JAVA_HOME=/Library/Java/JavaVirtualMachines/adoptopenjdk-8.jdk/Contents/Home
export ANDROID_HOME=/Users/$USER/Library/Android/sdk
Answered By - Nikitah
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.