To use cordova your need Java, Android SDK, and Gradle. If your take a peek at the source files, mainly platforms/android/cordova/lib/check_reqs.js
you can find the exact code that prints out the messages you get. Cordova checks environment variables you have set up on your system.
For Java, you need the JAVA_HOME variable, you can check variables by typing echo $JAVA_HOME
on your terminal if you're using linux. If the variable does not get printed out, you have to set it manually. Install java 8 and in your terminal you can set it with export JAVA_HOME="path_to_java"
. My path is /usr/lib/jvm/java-8-openjdk-amd64/
.
You need to do the same for ANDROID_HOME. When you install Android studio you will have the Android SDK installed. For me it's in my home directory /home/username/Android/Sdk
.
For Gradle you don't need to set env variables. You can install it with sudo apt install gradle
.
Note that once you close your terminal all the variables you added will disappear. You can make them permanent by adding the export
commands to your ~/.profile
file and rebooting your system. You can alternatively type source ~/.profile
in your terminal to load the variables into that terminal instance.
You may get an error about licences for Android. Just type path_to_your_sdk/sdk/tools/bin/sdkmanager --licenses
and accept all the licences.
If you have multiple Java versions installed Cordova may give you trouble since it doesn't only check the JAVA_HOME
variable, even though it only need that location. If you're confident that your JAVA_HOME
is set right, you can comment out lines 370-375 (the ones that throw an error when the following if statement is true !String(values[0]).startsWith('1.8.')
) in the platforms/android/cordova/lib/check_reqs.js
and Cordova will work fine.