38

enter image description here build-tools is: android-5.1

platform-tools updated

my platforms are
android-5.1
android-17

Glorfindel
  • 21,988
  • 13
  • 81
  • 109
Arsan Nazarnia
  • 397
  • 1
  • 3
  • 3
  • this should solve your problem: http://forum.ionicframework.com/t/error-could-not-find-gradle-wrapper-within-android-sdk-might-need-to-update-yo-ur-android-sdk/22056/2 – Sithys Jul 09 '15 at 07:21
  • for me is not showing the build-tools installed in Andorid sdk but i have the build-tools folder inside the sdk folder – Arsan Nazarnia Jul 09 '15 at 07:27
  • Solved my problem on Mac OSX by using that solution: http://stackoverflow.com/a/42772536/2030937 – totas Mar 14 '17 at 13:29
  • If you installed Android Studio and it's version is 2.3.1, see this solution http://stackoverflow.com/a/43383039/882410 – Xiaohui Zhang Apr 13 '17 at 03:29

15 Answers15

69

If you have Android Studio installed, try to copy the templates directory of Android Studio

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

to your android sdk tools directory:

C:\Android\sdk\tools

This did the trick for me :)

SMR
  • 6,628
  • 2
  • 35
  • 56
Nicolas
  • 2,684
  • 1
  • 16
  • 22
45

I had a similar problem with Android Studio running on a Mac.

I fixed it with the following commands:

cp -r /Applications/Android\ Studio.app/Contents/plugins/android/lib/templates ~/Library/Android/sdk/tools
chmod a+x ~/Library/Android/sdk/tools/templates/gradle/wrapper/gradlew
robbie_c
  • 2,428
  • 1
  • 19
  • 28
  • Thank you. After that I've also needed to update gradle to latest version (3.3 now) with AS, copy those gradle files to sdk location: `sudo cp -r ./platforms/android/gradle/wrapper ~/.android-sdk-macosx/tools/templates/gradle/wrapper/gradle & sudo cp ./platforms/android/gradlew ~/.android-sdk-macosx/tools/templates/gradle/wrapper & sudo cp ./platforms/android/gradlew.bat ~/.android-sdk-macosx/tools/templates/gradle/wrapper ` since on `prepare` cordova copies those files into project and set the build variable to 3.3 url according to http://stackoverflow.com/a/39278785/506954 – extempl Apr 05 '17 at 06:48
  • It occurs to me that you probably don't need the `sudo`. If someone tries this without and it succeeds, please report back :) – robbie_c Apr 14 '17 at 15:28
  • 2
    this worked for me when i got this error on my mac. I ran without sudo and it worked – Nearpoint Apr 16 '17 at 08:47
  • Thanks, `sudo` removed. If someone tries this now and it *doesn't* work, trying putting sudo before both lines. – robbie_c Apr 19 '17 at 10:38
  • 2
    You are the champion @robbie_c – Daniel Flippance May 10 '17 at 20:52
  • 3
    My savior! Saved my day. – Kumar Ravi May 11 '17 at 10:02
  • 1
    Thanks! Saved me a lot of time and trouble. – emccracken Jun 10 '17 at 18:48
  • 1
    Thanks! Been looking for a solution for 4 days and this worked! Awesome – SeppeDev Jun 11 '18 at 18:12
  • 1
    incredible A++++ – Dave Jan 14 '19 at 12:33
43

Update ANDROID_HOME path from

C:/Users/CURRENT_USER/android-sdk/tools/ 

to

C:/Users/CURRENT_USER/android-sdk

This should solve the problem When you build it appends tool automatically to your ANDROID_HOME therefore it searches for graddle inside tools/tools directory which is not present at all.

Musakkhir Sayyed
  • 7,012
  • 13
  • 42
  • 65
Rao
  • 441
  • 4
  • 2
19

I was having same error: could not find gradle wrapper within android sdk; When I was building ionic, but I solved it. I just downloaded Android SDK tools package and copied extracted file to C:\Users\CURRENT_USER\AppData\Local\Android\sdk and then issued: build ionic/cordova again.

it worked for me.

Vedant Terkar
  • 4,553
  • 8
  • 36
  • 62
Trisna
  • 385
  • 1
  • 5
  • 15
8

Got the same error in mac after updating the SDK Build Tools:

Error: Could not find gradle wrapper within Android SDK. Might need to update your Android SDK.  

Looked here: /Users/xxx/Library/Android/sdk/tools/templates/gradle/wrapper

Here is the method how I solved it:

  1. Copied templates folder from /Applications/Android Studio.app/Contents/plugins/android/lib to <ANDROID_HOME>/tools
  2. chmod -R 777 <ANDROID_HOME>

Good luck!

Avijit
  • 1,253
  • 13
  • 21
  • This worked for me. Pity I had to download the studio to get a hold of this stuff on a server. .5GB uncompressed – Chanoch Apr 21 '17 at 10:36
  • chmod =R 777 is really excessive. from @robbie_c's answer, all you need is: chmod a+x /tools/templates/gradle/wrapper/gradlew – Allan Nienhuis Nov 04 '17 at 21:19
5

update android project to cordova-android 6.2.1

cordova platform update android@6.2.1

for more details check the following links https://cordova.apache.org/announcements/2017/04/05/android-release.html

ahmy
  • 131
  • 2
  • 6
4

Have you checked the path manually ? (C:/Users/Arsan/android-sdk/sdk/tools/...)

I had to update my ANDROID_HOME path for this to work (to android-sdk/tools, so removing "sdk" from the path).

Steven

Steven
  • 41
  • 3
3

I had same issue... (2016-09-26, installed current version of Android SDK today)

ANALYSIS

I checked the installation and found out that the gradle wrapper is placed at a wrong location: ...\Android\SDK\tools\templates\gradle\wrapper\gradle\wrapper/[here_are_the_files]

Hence there is gradle/wrapper/gradle/wrapper in the end....

That folder conatins:

  • gradle-wrapper.jar
  • gradle-wrapper.properties

SOLUTION

Moving the content of that folder to the ...gradle/wrapper/-folder (hence 2 folders UPWARDS) solved my problem.

Hope that helps

Al Foиce ѫ
  • 4,195
  • 12
  • 39
  • 49
1

I have same issue: could not find gradle wrapper within android sdk when i build ionic, but i was solve. I just download Android SDK tools package361 and copy extract file to C:\Users\CURRENT_USER\AppData\Local\Android\sdk and build ionic/cordova again. Download link https://dl.google.com/android/repository/tools_r25.2.3-windows.zip

sqzaman
  • 636
  • 7
  • 5
1

None of the solutions worked for me as of today. My situation was that I got my Android studio updated. The most popular thing to replace the tools folder with the latest one wouldn't work for me. Infact is not required in some cases.

npm update -g cordova did the trick for me.

Then I removed the platform and added it again.

ionic platform remove android

ionic platform add android

This works for me in Ionic. I am sure cordova platform remove/add android will do the same stuff. Not tested though.

Working again !

HalfWebDev
  • 7,022
  • 12
  • 65
  • 103
  • I feel your pain. Every time I get an Android Studio upgrade it blows away the SDK tools breaking my cordova build. VERY annoying. – Brian Knoblauch Nov 15 '17 at 21:20
0

set ANDROID_HOME in system variable as follows

C:\Program Files\Android\android-sdk

And set path in user variale as follows

appropriate jdkpath ; C:\Program Files\Android\android-sdk\tools;C:\Program Files\Android\android-sdk\platform-tools
Amr Fawaz
  • 13
  • 2
  • I installed Android Studio as directed... the folder C:\Program Files\Android\android-sdk was not created. AS moved the SDK to a different location so this answer may be obsolete – WM1 Mar 29 '17 at 11:57
0

If you reinstalled Android Studio, there may be an sdk1 and also sdk folder in this path:

C:\Users\CURRENT_USER\AppData\Local\Android\

If you have two sdk folders you will have to delete one of them. Keep the one that contains the AVD Manager.exe and SDK Manager.exe.

This worked for me.

John Meyer
  • 2,296
  • 1
  • 31
  • 39
Gergő Kajtár
  • 454
  • 4
  • 12
0

In my case, some error occured during the Android Studio installation, and the tools/templates directory didn't exist. I fixed it by uninstalling and then reinstalling the Android SDK Tools, in the Android Studio Package Manager.

Marcos Lima
  • 761
  • 1
  • 10
  • 26
0

for my case: i figured out that templates folder is no longer available in the new sdk tools folder so:

0

Check whether your Android SDK having gradle/wrapper folder and having required files in that or not.If not update the Android SDK and try once.Make sure that you need set SDK root path in ANDROID_HOME in Environment variable in windows machines.

Narendrakumar
  • 163
  • 2
  • 6