Could not find gradle wrapper within Android SDK.

2019-01-16 14:04发布

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

5条回答
虎瘦雄心在
2楼-- · 2019-01-16 14:37

This worked for me

cordova platform update android@6.1.2

查看更多
在下西门庆
3楼-- · 2019-01-16 14:39

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).

查看更多
贼婆χ
4楼-- · 2019-01-16 14:45

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
查看更多
相关推荐>>
5楼-- · 2019-01-16 14:51

Edit:

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

cordova platform update android@6.2.2

or

cordova platform rm android
cordova platform add android@6.2.2

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 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.

查看更多
霸刀☆藐视天下
6楼-- · 2019-01-16 15:00

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.

查看更多
登录 后发表回答