Reputation: 37
I have a problem with the command ionic cordova build android.When I try to launch this command I have this error > cordova build android Checking Java JDK and Android SDK versions ANDROID_SDK_ROOT=undefined (recommended setting) ANDROID_HOME=/usr/lib/android-sdk (DEPRECATED) Requirements check failed for JDK 8 ('1.8.*')! Detected version: 11.0.3 Check your ANDROID_SDK_ROOT / JAVA_HOME / PATH environment variables. [ERROR] An error occurred while running subprocess cordova.
Upvotes: 0
Views: 3107
Reputation: 868
I was stuck on this for a bit, I had JDK 8 (1.8) installed but it wasn't finding it - adding the second line
export PATH=$JAVA_HOME/bin:$PATH
in my .bash_profile then running source ~/.bash_profile Saved the day - here's by full .bash_profile for reference
export JAVA_HOME="/Library/Java/JavaVirtualMachines/jdk1.8.0_251.jdk/Contents/Home"
export PATH=$JAVA_HOME/bin:$PATH
export ANDROID_HOME=/Users/dylan/Library/Android/sdk
export ANDROID_SDK_ROOT=/Users/dylan/Library/Android/sdk
export ANDROID_AVD_HOME=/Users/dylan/.android/avd
export PATH="${PATH}:/$ANDROID_HOME/platform-tools:/$ANDROID_HOME/tools:/$ANDROID_HOME/tools/bin"
export ANDROID_HOME=~/Library/Android/sdk
export ANDROID_SDK_ROOT=~/Library/Android/sdk
export ANDROID_AVD_HOME=~/.android/avd
Upvotes: 0
Reputation: 404
As others have said you need to update path variables, I want to add a few more parameters along these.
In the project, directory use this command to check Cordova compatibility.
$ ionic cordova requirements
This should show what you are missing.
Cordova needs Java JDK, Android SDK, Android target, Gradle.
Finally you need to sum up all these in path so command-line can recognise these.
Open .bashrc with $ ~/.bashrc
and add these lines. (If you haven't done already).
export JAVA_HOME="/usr/lib/jvm/java-11-openjdk-amd64" # change location
export PATH=$JAVA_HOME/bin:$PATH
export GRADLE_HOME=/opt/gradle/gradle-5.2.1 # change location
export PATH=${GRADLE_HOME}/bin:${PATH}
export ANDROID_HOME=$HOME/Android/Sdk # change location
export PATH=$PATH:$ANDROID_HOME/cmdline-tools/latest/bin
export PATH=$PATH:$ANDROID_HOME/platform-tools
Change locations based on your installation directory.
NB: Make sure to add this line export PATH=$PATH:$ANDROID_HOME/cmdline-tools/latest/bin
as old version of android studio's command-line has been deprecated and this is the updated command-line tool.
After this, reload the bash with $ sudo source ~/.bashrc
Then again check the requirements with ionic cordova requirements
and this should display:
> cordova requirements
Requirements check results for android:
Java JDK: installed 1.8.0
Android SDK: installed true
Android target: installed android-29,android-28,android-26,android-23
Gradle: installed /opt/gradle/gradle-5.2.1/bin/gradle
Upvotes: 0
Reputation: 1
I used to have the same issue in WebStorm and found solution. The issue is due to WebStorm was written in Java and use v11.0.3 inside. So, do the following: 1. Open Webstorm --> Help --> Find action --> Switch boot JDK --> Change path to your v.1.8. In my case it's: "C:\Program Files\Java\jdk1.8.0_231" 2. add "JDK_HOME" in environment variables in your OS and set it's value: "C:\Program Files\Java\jdk1.8.0_231" Restart your Webstorm. That's it!
This also might be helpful: https://intellij-support.jetbrains.com/hc/en-us/articles/206544879-Selecting-the-JDK-version-the-IDE-will-run-under
Upvotes: 0
Reputation: 1565
You need to set environment paths.
If your OS is ubuntu, try below.
sudo gedit ~/.bashrc
in gedit editor, add these lines
export ANDROID_HOME=/<installation location>/android-sdk-linux
export PATH=${PATH}:$ANDROID_HOME/tools:$ANDROID_HOME/platform-tools
Don't forget to save.
Upvotes: 0
Reputation: 1258
It is clearly saying you didn't set the java and environment paths
. To set up the environment follow Android environment setup
Link
Upvotes: 1