I have an older cordova project that I am updating. As a part of this process, I removed the android platform and readded it.
Now when I try to build the project I g
Resolved an error by following: Hi all, Resolved problem to run cordova run android via command prompt for cordova project attached problem screenshot. To resolve this problem removed all environment variables under Advanced System settings. Uninstalled java and installed again, downloaded old sdk tools to avoid prompt for eclipse now.
Under user variable added JAVA_HOME = C:\Program Files\Java\jdk1.8.0_131
Under System variable ANDROD_HOME = C:\cordova\android-sdk Path = C:\Program Files\Android\Android Studio2\gradle\gradle-3.2\bin\;%JAVA_HOME%\bin to avoid error: No installed build tools found. Install the Android build tools version 19.1.0 or higher. Problem resolved now
The problem was that my gradle version was 2.1 where Cordova wanted 3.2. Updating Android Studio (It was at 2.1) and making sure the environment variables are upto date was the main trick to get it to work again.
You can downgrade cordova cli using
npm install -g cordova@6.4.0
and build the project with give command
ionic cordova build android
no need to add platform, it'll automatically add. If it ask to update cordova cli, then choose no
I found another solution by downgrading Android to version 6.1.2, since the suggestions here (and many other suggestions on various forums, like reinstalling plugins, etc.) didn't work for me:
cordova platform update android@6.1.2 --save
If that doesn't work at first hand, try the following:
First remove android platform:
cordova platform remove android
Add Android version 6.1.2:
cordova platform add android@6.1.2
Build Android:
cordova build android
Here are some additional steps I took prior to above (on Mac), just to make sure:
Download the latest JDK and install.
Add JAVA_HOME this way:
echo export "JAVA_HOME=\$(/usr/libexec/java_home)" >> ~/.bash_profile
Restart shell (CMD+Q and open again)
Make sure echo $JAVA_HOME
equals to Android Studio -> File -> Project Structure -> JDK Location
For me, this is the following path and version:
/Library/Java/JavaVirtualMachines/jdk1.8.0_144.jdk/Contents/Home
Update Android Studio and all of the SDK packages
Update npm
npm update -g
Note: On OS X 10.11 El Capitan or greater, run:
sudo npm update -g --unsafe-perm=true
Update Cordova
npm update -g cordova
If all of this didn't work for you and you are left with no other choice, I suggest you try downgrading Cordova to version 6.4.0:
npm update -g cordova@6.4.0