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

63,339

Solution 1

Edit:

There has been a newer release of Cordova Android that also fixes some problems with SDK tools 26.x.x

cordova platform update [email protected]

or

cordova platform rm android
cordova platform add [email protected]

Old answer

Google broke Cordova Android 6.1.x and some other frameworks with their latest sdk tools update.

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 [email protected]

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 [email protected]

You have to specify the version because current CLI installs 6.1.x by default.

Solution 2

I resolved by this by replacing the tools folder in my Android SDK with an older version of the SDK tools (r25.2.3). Follow these steps to do the same:

  1. Navigate to https://developer.android.com/studio/index.html, click "Download Options", scroll down, and download the command line tools package for your platform, ensuring that you get a version in the r25.2.X series (not r25.3.X).
  2. Unzip this folder. You should end up with a tools directory.
  3. Navigate to your $ANDROID_HOME directory (~/Library/Android/sdk/ on OS X).
  4. Rename the pre-existing tools directory there to tools.bak (e.g., mv tools tools.bak)
  5. Move the tools directory you just downloaded into the SDK folder (e.g., mv ~/Downloads/tools/ .)

A new major version of the SDK tools was just released, which appears to be causing some issues with Ionic (see the press release here: http://tools.android.com/recent/androidsdktoolsrevision2530feb2017).

Solution 3

This worked for me

cordova platform update [email protected]

Solution 4

There's no need to downgrade Android Tools. On Windows gradle moved from:

C:\Users\you_username\AppData\Local\Android\sdk\tools

to:

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

So you just need to ajust your path so that it points to the right folder.

Solution 5

I had same problem and I solved it with Carlos Delgado's answer.

  • Android Path must be set before all things below.
  • Download the latest command line tools (https://developer.android.com/studio/index.html -> very bottom part)
  • Unzip -> copy and paste "tools > templates" folder to your project folder (/Libraries/Android/sdk/tools/)
  • press option key to see Libraries folder in your Finder
Share:
63,339
Admin
Author by

Admin

Updated on April 29, 2020

Comments

  • Admin
    Admin about 4 years

    I am trying to take build in an ionic2 application. I got this error while running ionic build android. The error log is

    ANDROID_HOME=/home/varun/Android/Sdk
    JAVA_HOME=/usr/lib/jvm/java-8-oracle
    Error: Could not find gradle wrapper within Android SDK. Might need to    update your Android SDK.
    Looked here: /home/varun/Android/Sdk/tools/templates/gradle/wrapper
    

    I tried updating the sdk but it was found that the sdk version is latest.

    When i looked at the Android/Sdk/tools folder there is no templates directory. I am running on ubuntu 16.04, with cordova version 6.5.0

  • Sebastián Rojas
    Sebastián Rojas about 7 years
    DETAILS PLEASE, how do you "Change tools directory to tools_r25.2.3 directory."?
  • cesarvargas
    cesarvargas about 7 years
    I think he meant to put all the files from r25.3.1 on the previously installed tools folder.
  • Carlos Delgado
    Carlos Delgado about 7 years
    Indeed, downloading the latest command line tools and paste its content in the /Android/sdk/tools folder solved the problem ;)
  • shaunc
    shaunc about 7 years
    AFAIKT I was able to get away with just copying the old tools/templates subdirectory into the Android/sdk/tools folder.
  • shareef
    shareef about 7 years
    Yes It WORKED thankks
  • Oleg
    Oleg about 7 years
    Thank you! It's really works!
  • dsp_099
    dsp_099 about 7 years
    Didn't fix the issue for me.
  • jcesarmobile
    jcesarmobile about 7 years
    @dsp_099 did you remove android platform first? if you run cordova platforms what cordova-android version do you get?
  • dsp_099
    dsp_099 about 7 years
    I see "Installed platforms: android 6.1.2. See latest question on my profile for more info"
  • jcesarmobile
    jcesarmobile about 7 years
    then do a cordova platform rm android first and then cordova platform add https://github.com/apache/cordova-android, you should get 6.2.0-dev instead of 6.1.2
  • dsp_099
    dsp_099 about 7 years
    Step in the right direction... That helped... sort of. See my question here, seems to be the issue, might give you more intel.
  • Suraj Dubey
    Suraj Dubey about 7 years
    it worked, thanks :)
  • Pier
    Pier about 7 years
    Thanks that fixed it for me after updating SDK tools to 25.3.1
  • mentat
    mentat about 7 years
    where do we adjust it? in cordova?
  • Playdome.io
    Playdome.io about 7 years
    I get a warning: cmd: command failed with exit code 1 Can i get rid of it somehow?
  • jcesarmobile
    jcesarmobile about 7 years
    @Azarus which command?
  • Playdome.io
    Playdome.io about 7 years
    When upgrading the android platform, this seems pretty messed up right now. :/ Spent like 4 hours just setting things up huh
  • Elemental
    Elemental about 7 years
    you sure you don;t mean @6.2.1?
  • ben_joseph
    ben_joseph about 7 years
    @mentat update it in the windows path.
  • Pedro Miguel Pimienta Morales
    Pedro Miguel Pimienta Morales about 7 years
    Can you explain better, excuse me, i don't get the part, tools > templates, i need copy the tools folder into template, o what project you say?
  • Herman Demsong
    Herman Demsong about 7 years
    Thanks man, this worked fine for me
  • Adam
    Adam about 7 years
    You little beauty.
  • Lifz
    Lifz almost 7 years
    Fantastic. Running cordova platform update android worked perfectly. It updated to 6.2.3. It must know to look for gradle in the new directory: C:\Program Files\Android\Android Studio\plugins\android\lib\templates\gradle\wrapper
  • ChickenFeet
    ChickenFeet over 6 years
    How is 6.2.2 a newer release when OP has 6.5.0 ? The two solutions to this problem involve either downgrading Android SDK or Cordova, it doesn't seem like a very sustainable solution - you're going to have to upgrade eventually right?
  • jcesarmobile
    jcesarmobile over 6 years
    @ChickenFeet No, you are confusing cordova-lib (or Cordova CLI) version with cordova-android version. Cordova CLI 6.5.0 had cordova-android 6.1.1, so, by the time I wrote this, he needed to upgrade the cordova-android version to 6.2.2. Now there is a new Cordova CLI version (7.0.1) that uses cordova-android 6.2.x as default.
  • Mirko
    Mirko over 6 years
    I am sure, that is the version I am using
  • androticus
    androticus almost 6 years
    This did not work for me. It still gave the same "can't find gradle wrapper" comment
  • Ananta Prasad
    Ananta Prasad over 5 years
    cordova platform update [email protected] fixed my issue. thanks bro..:)
  • jcesarmobile
    jcesarmobile over 5 years
    @LAnantaPrasad at this point you also have 6.4.0 or 7.1.4 available, that also have the problem fixed and are newer
  • Ananta Prasad
    Ananta Prasad over 5 years
    @jcesarmobile thanks
  • Joe
    Joe over 5 years
    I've been working on this for 3 days. You save my life. Thanks.
  • mahendren
    mahendren about 5 years
    This is working for me thanks dude......