FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':preBuild'.
> failed to find target android-22 : /Users/franciskim/Library/Android/sdk
I am getting the above error when running ionic run android
. This is a brand new project, I had added Crosswalk at the start however it is removed now - it did not make a difference. I do have API 22 installed:
Same thing happens on a brand new project. I’m currently installing everything under API 22.
I’ve run all the possible updates, now getting:
Could not find gradle wrapper within Android SDK. Might need to update your Android SDK.
Finally figured it out, after upgrading everything, the problem was path:
export ANDROID_HOME=/usr/local/Cellar/android-sdk/24.1.2
export PATH=${PATH}:$ANDROID_HOME/tools:$ANDROID_HOME/platform-tools
export GRADLE_HOME="/usr/local/Cellar/gradle/2.7"
export PATH=${PATH}:$GRADLE_HOME/bin
Seems a problem with gradle, at line 346 of file platforms/android/cordova/lib/build.js
I’ve resolved downloading http://services.gradle.org/distributions/gradle-2.2.1-all.zip
Then I’ve put this file on htdocs on localhost, then changed line 346 to
var distributionUrl = 'distributionUrl=http://localhost/gradle-2.2.1-all.zip';
I know that is not a perfect solution, but works for me
I tried a similar approach, but it didn’t work for me (was relative path, without localhost though)