Cordova gradle wrapper missing in android sdk - android

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.

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

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

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.

Related

"cordova build android" fails with "no installed build tools found"

I have looked EVERYWHERE for the solution to this.
Ionic Cordova Build Android No installed build tools found did not work
cordova build android failed with exception was a ridiculous non-answer. OF COURSE Android Studio is installed!!!
Android studio- "SDK tools directory is missing" I did this. The $ANDROID_SDK_ROOT/tools folder now exists, but that didn't solve my problem.
I tried the advice given here: Ionic Cordova Build Android No installed build tools found and all I get when I run sdkmanager packages "build-tools;30.0.3" is "failed to find package 'packages'" from the SDK Manager.
I looked here: Android SDK Manager does not exist and installed ALL the stuff they said to install -- including the obsolete packages. And still no luck.
Here's my path:
/opt/homebrew/bin:/Users/lmacneill/.sdkman/candidates/java/current/bin:/Users/lmacneill/.sdkman/candidates/gradle/current/bin:/usr/local/bin:/System/Cryptexes/App/usr/bin:/usr/bin:/bin:/usr/sbin:/sbin:/Library/Apple/usr/bin:/Users/lmacneill/CordovaProjects/gamapp/node_modules/.bin:/Users/lmacneill/Library/Android/sdk/tools:/Users/lmacneill/Library/Android/sdk/build-tools:/Users/lmacneill/Library/Android/sdk/platform-tools
Here's my Android Studio SDK Platforms screen:
https://i.stack.imgur.com/2e5YI.png
And here's my Android Studio SDK Tools screen:
https://i.stack.imgur.com/btLIR.png
(Unrelated to this post, but very weird -- it told me I needed 10 reputation to post images, yet I have 661 reputation. Why did it do that? Hence the link to my images instead of the actual images.)
SO WHY CAN THE TOOLS NOT BE FOUND?!!!!!!. I've done EVERYTHING that EVERYONE has suggested, and STILL IT DOESN'T WORK!!!!
This is ridiculous!!!! Surely someone must know the answer?
Well... I FINALLY figured it out...
In the $ANDROID_SDK_ROOT/build-tools folder, there was a 33.0.2 folder. So in my .zshrc file, instead of adding $ANDROID_SDK_ROOT/build-tools to the path, I needed to add $ANDROID_SDK_ROOT/build-tools/33.0.2 to the path.
Then cordova build android FINALLY worked!!!
BTW, I figured this out when I finally got sdkmanager to install the build-tools;30.0.3 -- you have to use sdkmanager "build-tools;30.0.3" command, NOT the sdkmanager packages "build-tools;30.0.3" command. Maybe the command with the 'packages' bit worked for an older version of sdkmanager? But it definitely doesn't work now. Anyway, once I saw that it had created a new folder in $ANDROID_SDK_ROOT/build-tools, I finally realized that exporting only $ANDROID_SDK_ROOT/build-tools in the path wasn't enough. You have to include the version folder in there as well.
ANDROID!!! Y'ALL SHOULD MAKE THIS EASIER!!!! INSTALLING ANDROID STUDIO SHOULD DO ALL OF THIS STUFF AUTOMATICALLY!!!!!

Error about Android Studio on Macbook M1: An error occurred while trying to compute required packages

I've downloaded Android Studio from the official website, the one for M1 chip (arm).
Basically running it for the first time, the error is the following:
An error occurred while trying to compute required packages
I was searching about it the whole day to figure out a way to make Android Studio work, but that error keeps showing. Not completely sure if it's related to M1 Macbook, as on my Intel one it works as expected.
What I already tried to do:
Installing the command line tools, then placing it on SDK folder (Users/user/Library/Android/sdk). Then added the bin to the PATH (Reference)
After doing that, when executing the sdkmanager on terminal I get the following message Could not find or load main class com.android.sdklib.tool.sdkmanager.SdkManagerCli
Then I searched again and it leaded me to this thread, then as on the answers I tried to rename the folder, then other tries not related. I fell into many links and references that did not work at all.
After that I try to check what happens if I click on New Project, then the following is shown:
The Android SDK location cannot be at the filesystem root
As the message indicates, the issue is The Android SDK location cannot be at the filesystem root, so I searched again about it
I looked into that and got to a few links, for example this one and this one. Before doing that search I clicked on the Edit button, which lead me to the Android SDK to be updated/installed (Nice!), so I had to delete the content I had on Android folder (inside Library) and clicked next...then, I got the same message An error occurred while trying to compute required packages.
Then I thought "ok, maybe if I change the SDK location", so I changed to ../Documents/sdk, which ended up in the same result
Seems like no matter what I do, it ends up showing up that same message.
When I run java -version that's what I see:
java version "1.8.0_311"
Java(TM) SE Runtime Environment (build 1.8.0_311-b11)
Java HotSpot(TM) 64-Bit Server VM (build 25.311-b11, mixed mode)
Did anyone have the same issue? Am I doing something wrong? Not sure how to proceed from here, despite of the Android Studio version I download it's always the same result.
Any help is appreciated.
This is what solved it for me on my M1.
Go to Android Studio Preview and download the latest Canary build for Apple chip (Chipmunk). Don't worry this is just to get through the initial setup.
Unpack it, run it, let it install all the SDK components, accept licenses, etc as usual.
Once it's done, simply close it and delete it.
Now when you start your stable Android Studio (Arctic Fox) you should not see the error.
I tried over a dozen 2021 stable and Canary builds from https://developer.android.com/studio/archive and couldn't get any of them to work.
This is the only thing I could find that worked:
Download, unpackage and run Android Studio 3.6.3 android-studio-ide-192.6392135-mac.zip from here.
Proceed through the initial setup and let it download and install the SDK. Ignore any errors at the end.
Delete this version and open the stable Android Studio like normal.
You can now proceed through setup!
I also faced this issue a couple days and I changed my mind to not use Android Studio. And It's fixed!
My alternative option is to download IntelliJ community edition and install Android SDK to your machine.
Image for IntelliJ Download Page
After (IntelliJ) installation is complete,
You need also to create new project, select android then download SDK. (thanks for #SteveRoger 's comment)
then open Android Studio again and follow its setup wizard. It will show that my machine has been already installed Android SDK and it can run perfectly at this time.
Hope this is an alternative solution for you.
Have a great day.
I solved the problem with these steps:
Install the old Android Studio 3.6.3 (find the old Android Studio at https://developer.android.com/studio/archive)
Install the Android SDK
Overwrite the installation with the Apple Chip version of Android Studio
I had the same problem with my MacBook air(m1 chip) as you mentioned.
How did I solve it?
Just download the IDE - Intellij IDEA and create a new project, select Android Project and there download Android SDK, now you can install android studio again and the sdk is installed.
I've also had this exact same issue when downloading Android Studio 7.0.3. Here's what helped me.
Download the command line tools, place them in the SDK folder (e.g., on mac: /Users/user/Library/Android/sdk), and then add the bin folder to the PATH.
Install the latest platform: in a terminal, execute ./sdkmanager "platforms;android-31"
Next up execute this command ./sdkmanager --channel=3 emulator (this switches the channel from stable=0 to canary=3 )
Open Android Studio, and go to the SDK Manager (Appearance and Behavior > System Settings > Android SDK)
Click on "Edit", and then select the sdk folder. Then "Next" > "Next" > "Finish".
Now restart Android Studio and everything should work
I had the exact same error as OP. Follow what Art Fedorychak mentioned, it worked for me as well. It seems like the current stable build of the Apple M1 android studio version doesn't actually initialize an SDK if one doesn't already exist, but it seems to be able to update and or / initialize one that does as long as the same folder is being referenced, so we just need to use a working SDK for M1 on the initial run and then revert back to the stable AS
This is what solved it for me:
Download & install IntelliJ IDEA. https://www.jetbrains.com/idea/download/#section=mac
Open IntelliJ IDEA and create New Android Project
Download sdk success
Open Android Studio & checked it worked
My solution to this problem is simply to put the SDK in another location. For myself, I put the SDK folder to subfolders in Documents. The SDK download will initiate.

Cordova fails to find ANDROID_HOME environment variable

I looked all over Google and Stack Overflow for an answer, but I couldn't find the right one for me. I am learning Cordova and I'm trying to run the android emulator through terminal, and when I run 'sudo cordova emulate android' I get this message:
''Failed to find 'ANDROID_HOME' environment variable. Try setting it manually.
Detected 'avdmanager' command at /Users/username/Library/Android/sdk/cmdline-tools/latest/bin but no 'tools/bin' directory found near.
Try reinstall Android SDK or update your PATH to include valid path to SDK/tools/bin directory.''
But I set the variables in the ~./bash_profile file and it looks like this:
export ANDROID_HOME="/Users/username/Library/Android/sdk"
export ANDROID_SDK_ROOT=$ANDROID_HOME
export PATH=${PATH}:$ANDROID_HOME/cmdline-tools/latest/bin:$ANDROID_HOME/platform-tools
export PATH=${PATH}:$ANDROID_HOME/tools/bin
export PATH="$PATH:$ANDROID_HOME/build-tools/30.0.0-rc2"
I am using a MacOS Mojave, does anyone know what the issue is?
Thanks in advance
Apparently, in the latest version of Android Studio, the old SDK tools (under /tools, which Cordova seems to expect) are already considered obsolete. There is a solution documented here on how to install the old version of SDK tools.
Open Android Studio
Open Tools -> Sdk Manager
Click on the Sdk Tools Tab
Uncheck Hide Obsolete Packages
Check Android Sdk Tools (Obsolete)
Click Apply
This should download the old SDK tools under the correct folder.
However, I think Cordova also needs to keep up with the newest Android development tools. There's another change I needed to make after this:
I had to delete the tools/emulator and tools/emulator-check binaries, and add $ANDROID_HOME/emulator to my $PATH, since the current emulator binary lives under emulator/emulator instead of path/emulator. See this post.
Then I was finally able to launch the app directly via Cordova.

Android Studio Can't Find JDK Mac

I'm just trying out Android Studio. I imported a project from Eclipse, but every time I try
to run it I get this error:
"Cannot run program
"Library/JavaVirtualMachines?jdk1.7.0_10.jdk/Contents/Home/bin/java"
(in directory
"/Users/myname/Library/Caches/AndroidStudioPreview/compile-server"):
error=2, No such file or directory.
I just installed the latest JDK using the JDK 7 Update 21 dmg. Is it installing the jdk in a place where Android Studio won't find it? The dmg didn't have any options for where to install the jdk other than "Install for all users of this computer," which I did.
When I was using Eclipse I had no problems with running my programs.
Furthermore, the Project Structure option was no longer available after I updated earlier today. Instead I just get the message, We will provide a UI to configure project settings later. Until then, please manually edit your build.gradle file(s.)"
I'm not sure what to do to get my programs running again. Do I need to locate the jdk files and move them? Could I tell Android Studio where the files are actually installed?
The solution was easier than I thought: just go to File/Other Settings/Default Project Structure and click SDKs. There the JDK home path can be changed.
Yes changing the JDK path will work. If that doesn't fix your problem, as it didn't for me at first, uninstall your JDK and redownload and install it. Once I reinstalled mine, it worked flawlessly.

platform-tools\aapt.exe directory missing in android SDK

I'm trying to get 'hello world' working on the Android SDK with Eclipse. I'm following this tutorial step by step:
http://developer.android.com/resources/tutorials/hello-world.html
but i'm returned the error "Error executing aapt. Please check aapt is present at C:\android-sdk-windows\platform-tools\aapt.exe"
For some reason, the "platform-tools" folder does not exist under my installation. In its place I find "platforms" and "tools". Presumably, my SDK version is different to that used in the tutorial.
I can't work out what i need to change or update. Can someone please point me in the correct direction?
Thank you
Totally agree with izzy, but other times (usually on 64 bit OS machines or with multiple android platforms) when you install the latest SDK version the folder platform-tools had missing the "appt.exe".
To solve this you need to search on *android-sdk\build-tools* folder and subfolders like \build-tools\17.0.0 in my case, and you will find aapt.exe, other necesary files and lib folder, just copy it everything to android-sdk\platform-tools and it will be done.
sometimes you may get the error that it can not install because it can not create the temp folder to install the tools. You simply just need to run the SDK manager as administrator and this will allow it to all work out.
if we will face appt.exe issue (could not found) just Follow the below steps:
1. Just Read It(https://developer.android.com/studio/command-line/aapt2)
Navigate to (ctrl+find and search) com.android.tools.build > then go to aapt2 from this url (https://dl.google.com/dl/android/maven2/index.html)
Insert the version name you copied into the following URL and specify your
target operating system: https://dl.google.com/dl/android/maven2/com/android/tools/build/aapt2/aapt2-version/aapt2-aapt2-version-[windows | linux | osx].jar
For example, to download version 3.2.0-alpha18-4804415 for Windows,
you would use: https://dl.google.com/dl/android/maven2/com/android/tools/build/aapt2/3.2.0-alpha18-4804415/aapt2-3.2.0-alpha18-4804415-windows.jar
Extract the jar file, Change the name aapt2.exe to apt.exe
Copy and paste into your android-sdk -> platform-tools
Run the program, Issue will be get resolved
Note: Means you have to download and set the aapt.exe path in System Environment Variable
*What version of the SDK are you running? (1.5_r2 or something?)*
I would suggest updating your SDK and be done with it ;)
You can do so trough the "Android SDK and AVD Manager".
Eclipse:
menu->window->"Android SDK and AVD Manager"
You might also want to change this setting:
menu->window->preferences->install/update->(expand)->automatic updates
Run the Android SDK Manager and be sure that you have checked and installed Tools>Android SDK Platform-tools.
I believe this package is responsible for the folder in question here.
I just found aapt.exe file in my latest Android-SDK folder (Android_SDK\build-tools\28.0.3)
You can check your latest sdk build-tools folder
or
You can search on total Android SDK folder by file name
I was able to delete my version (28.0.3) and Android Studio reinstalled it. The directory location was
C:\Users\YourUserName\AppData\Local\Android\Sdk\build-tools

Categories

Resources