Programmers learn & share
0 votes
53 views

Problem :

I am working on the Ionic project in Ubuntu 16.04 LTS, and now I am preparing for release. So I am running the following command:

cordova build --release android

But I am facing 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 am not having the templates/gradle/wrapper directory.

·   I am having the latest version of Android Studio is 2.3 for now

·   I am having Android SDK Platform-Tools 25.0.3

·   I am having Android SDK Tools 25.3.1

·   I am having  All Android versions from 2.1 (Eclair) to 7.1.1 (Nougat)

Does anybody have any clue on this error?

by (7.5k points)   | 53 views

2 Answers

0 votes

Solution:

1.  If you are having the android studio installed within your system then you just need to copy the templates folder from following path :

C:\Program Files\Android\Android Studio\plugins\android\lib\templates

2.  After that you need to Paste it in the following folder

C:\Users\<user-name>\AppData\Local\Android\sdk\tools 

3. Now you need to Run the command following command:

ionic build android

 It will download all the necessary jar files and will also generate the apk file for the application.

Please set your environment variables to C:\Users\<user-name>\AppData\Local\Android\sdk\tools. And also set user-name to your current username.

by (36.1k points)  
0 votes

It can be an obstruction in the instruction list of how to install or upgrade Andriod studio will all SDK tools which you have missed. This creates a bug by a new release of the studio which does not follow the same file conventions as the older version allows. Since many posts on this topic seem to point to an Andriod_Path folder with a folder called andriod_sdk which does not seems to be supported in the latest versions

Solutions:

Solution 1:

Here you just need to follow the following steps to solve this error:

  • Download tools_r25.2.3-windows.zip from Andriod Downloads.
  • Extract this zip file on the desktop.
  • Replace C:\Users\username\AppData\Local\Andriod\sdk\tools with sub-folder tools/
  • Go to your project folder and add;
$ cordova platforms remove andriod

$ cordova platforms add android

You may also need to force remove the node_modules in andriod. 

Sadly Andrios SDK tools 25.3.1 broke cordova-andriod 6.1.x:

For those who want to downgrade the SDK tools, you can install cordova-andrios from the URL as most of the errors are already fixed on the master branch

Cordova platform add https://github.com/apache/cordova-andriod

Solution 2:

  • If you have andriod studio installed on your system, then copy the templates folder from C:\Program Files\Andriod\Andrios Studio\plugins\andriod\lib\templates
  • Paste it the folder C:\Users\<user-name>\AppData\Local\Andriod\sdk\tools
  • Run the command
ionic build andriod

All the required jar files will be downloaded and an apk file for application will be generated.

 

by (2.8k points)  
2,227 questions
2,734 answers
59 comments
241 users