Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
menu search
person
Welcome To Ask or Share your Answers For Others

Categories

I know there are lots of questions similiar to this one, but i couldn't find a solution for my problem in any of those. Besides, I'll provide details for my specific case.

I coded an Ionic project in Ubuntu 16.04 LTS, and now I have to build it for release. So I run the command:

cordova build --release android

And I'm shown the following error:

Error: Could not find gradle wrapper within Android SDK. Might need to update your Android SDK.
Looked here: /home/user/Android/Sdk/tools/templates/gradle/wrapper
  • I don't have this templates/gradle/wrapper directory.
  • My Android Studio is 2.3, the latest version for now
  • Android SDK Platform-Tools 25.0.3
  • Android SDK Tools 25.3.1
  • All Android versions from 2.1 (Eclair) to 7.1.1 (Nougat)

After extensive research, I put all the Android Studio-related environment variables in the file /etc/environment. So now it looks like this:

PATH="/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/game:/home/<user>/Android/Sdk:/home/<user>/Android/Sdk/tools:/home/<user>/Android/Sdk/platform-tools"

ANDROID_HOME=/home/<user>/Android/Sdk
export ANDROID_HOME

JAVA_HOME=/usr/lib/jvm/java-8-oracle
export JAVA_HOME

GRADLE_HOME=/opt/android-studio/gradle/gradle-3.2
export GRADLE_HOME

Now, for the sake of testing the environment variables, I run the following commands:

source /etc/environment
echo $PATH
echo $ANDROID_HOME
echo $JAVA_HOME
echo $GRADLE_HOME

And all the path variables are correctly displayed.

So, it looks like the environment variables are like they should be according to the various similar questions and in tutorials i've searched. Does anyone know what am I doing wrong? Why do I still get the Gradle Wrapper error?

Question&Answers:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
1.1k views
Welcome To Ask or Share your Answers For Others

1 Answer

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 android@6.2.2

or

cordova platform rm android
cordova platform add android@6.2.2

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 android@6.2.1

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 android@6.2.1

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


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
...