Edit 3:
Cordova Android 6.2.2 has been released and it's fully compatible with SDK tools 26.0.x and 25.3.1. Use this version:
cordova platform update [email protected]
or
cordova platform rm android
cordova platform add [email protected]
Edit 2:
There has been another Android SDK tools release (26.0.x) that is not fully compatible with cordova-android 6.2.1.
Edit: Cordova Android 6.2.1 has been released and it's now compatible with latest Android SDK.
You can update your current incompatible android platform with
cordova platform update [email protected]
Or you can remove the existing platform and add the new one (will delete any manual change you did inside yourProject/platforms/android/
folder)
cordova platform rm android
cordova platform add [email protected]
You have to specify the version because current CLI installs 6.1.x by default.
Old answer:
Sadly Android SDK tools 25.3.1 broke cordova-android 6.1.x
For those who don't want to downgrade the SDK tools, you can install cordova-android from github url as most of the problems are already fixed on master branch.
cordova platform add https://github.com/apache/cordova-android
I just experienced the same problem.
It may be an occlusion in the instructions regarding how to install (or upgrade) Android Studio with all the SDK Tools which both you and I missed or possibly a bug created by a new release of Studio which does not follow the same file conventions as the older versions. I lean towards the latter since many of the SO posts on this topic seems to point to an ANDROID_PATH with a folder called android-sdk which does not appear in the latest (2.3.0.8) version.
There appears to be a workaround though, which I just got to work on my machine. Here's what I did:
Download tools_r25.2.3-windows.zip from Android Downloads.
Extracted zip on desktop
Replaced C:\Users\username\AppData\Local\Android\sdk\tools with extracted sub-folder tools/
In project folder:
$ cordova platforms remove android
$ cordova platforms add android
You may also need to force remove the node_modules in android. Hopefully this helps.
(Basically what @user3464070 already said)
For Mac:
cd ~/Library/Android/sdk
# download latest tools
curl -O https://dl.google.com/android/repository/tools_r25.2.3-macosx.zip
# overwrite existing tools folder without prompting
unzip -o tools_r25.2.3-macosx.zip
# clean up
rm tools_r25.2.3-macosx.zip
C:\Program Files\Android\Android Studio\plugins\android\lib\templates
C:\Users\<user-name>\AppData\Local\Android\sdk\tools
ionic build android
All necessary jar files will be downloaded and apk file for the application will be generated.
Note: Set environment variables to
C:\Users\<user-name>\AppData\Local\Android\sdk\tools
.
Also set user-name to your current username.
For Linux there is even a bit better solution.
Navigate to https://developer.android.com/studio/index.html#downloads
and download the command line tools zip file (bottom of the page) for linux. Extract them to your ..../Android/Sdk/ folder so you overrwrite/extend your tools folder. Now everything works fine.
For anyone who is still having this issue, this worked for me:
cordova platform update android@latest
then build and it will automatically download the newest gradle version and should work
There's no need to downgrade Android Tools. On Windows, Gradle moved from:
C:\Users\you_username\AppData\Local\Android\sdk\tools
to:
C:\Program Files\Android\Android Studio\plugins\android\lib\templates\gradle\wrapper
So you just need to adjust your path so that it points to the right folder.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With