12

I'm on windows7 x64, installed today's latest stable release of android sdk studio (through android studio bundle, since it's shipped together now apparently). I have properly configured the environment variables as you'll see above.

This is what I get when issuing the following command

$ cordova build android

ANDROID_HOME=G:\installs\Android\sdk
JAVA_HOME=C:\Program Files\Java\jdk1.8.0_121
Error: Could not find gradle wrapper within Android SDK. Might need to update your Android SDK.
Looked here: G:\installs\Android\sdk\tools\templates\gradle\wrapper

And indeed, the "templates" directory doesn't even exist in my sdk install.

I've already tried the suggestions (setting the right path, uninstall/reinstall) of this question here but nothing applies to my case, and I find that manually copying and pasting packages is not really a solution, since there's a package manager in place.

If anybody has an answer as of today's android install, would be very much appreciated.

Gaurab Kumar
  • 2,144
  • 2
  • 17
  • 29
wiwi
  • 270
  • 2
  • 9
  • See my answer [here](http://stackoverflow.com/questions/42667277/cordova-phonegap-android-target-not-installed-android-studio-installed/43565291#43565291) for the nitty gritty. – JGFMK Apr 23 '17 at 06:56

3 Answers3

12

If still not working then copy all file from gradle\wrapper from Android Studio installation folder

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

and paste it in your Android SDK gradle\wrapper then run same command.

E:\android-sdk\tools\templates\gradle\wrapper

Gaurab Kumar
  • 2,144
  • 2
  • 17
  • 29
7

This is a known issue; see CB-12544. For now you'll need to downgrade.

Kerri Shotts
  • 2,372
  • 1
  • 17
  • 19
  • Thanks for the answer Kerri. Even though it's bad news for me to downgrade. But since I am a beginner in this world, do you have a suggestion as to how to do that effectively with my actual install? – wiwi Mar 07 '17 at 16:19
  • I'm not completely certain -- I haven't upgraded, so I don't have an environment with which to test. You might try downloading an older version of the SDK tools from the SDK Manager (Android Studio or `sdkmanager` at the CLI), but I'm not 100% if that will work or not. – Kerri Shotts Mar 07 '17 at 17:56
  • No worries, I'll try to dig deeper into this topic. Too bad to have so much trouble just by installing a sdk. Thank you for the help :) – wiwi Mar 07 '17 at 18:05
  • downgrade sdk or what exactly? – shareef Mar 14 '17 at 17:19
  • Saw this link on a downgrade option on the slack channel from @Filmaj: https://github.com/apache/cordova-android/pull/367#issuecomment-286166329 Alternatively, you can use his fork of `cordova-android` to work with the current version: https://github.com/filmaj/cordova-android/tree/CB-12546 – Kerri Shotts Mar 15 '17 at 19:30
  • 2
    `cordova platform add android@6.2.0` is working since last night, although automatic discovery isn't working for it yet. – Jules Apr 01 '17 at 06:18
  • 1
    But still this is (almost) a link only answer. Links can break, go down. So: you could add a short summary from that link! – GhostCat Apr 04 '17 at 14:45
2

I downloaded Android SDK r25 manually and placed templates folder inside Android/sdk/tools. This solved the issue for me. You can get it from https://dl.google.com/android/repository/tools_r25.2.3-macosx.zip

For Windows:

https://developer.android.com/studio/index.html

Go to the section :"Get just the command line tools"

There is a link 'sdk-tools-darwin-3859397.zip' for Mac, Unfortunately that didn't have the templates folder with Gradle Wrapper. So for Mac users, i will suggest not to go for this zip.

Siena
  • 778
  • 10
  • 23
  • I have installed the zip for macOS and the error is gone but it was replaced buy another one: `>> Error: Cannot read property '1' of null` `>> Exited with code: 1.` – csalmeida Nov 17 '17 at 16:21
  • This worked for me. I downloaded the linked zip, extracted it to a new folder, grabbed the tools/templates/gradle folder and dropped it into tools/templates (which I had to mkdir) in the installed sdk and building now finds gradlew (this is cordova 7.1 with android 26.1.1 sdk macOS Mojave) – Austin France Nov 22 '18 at 12:12