Issue
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/wrapperdirectory. - 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?
Solution
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.
Answered By - R J
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.