Is gradle installed with Android Studio on Windows? - android-studio

I'm on Windows 10 and I have Android Studio installed and a version of the SDK installed. If I wish to use gradle on my command line(I'm running cordova requirement), how do I find out the path of gradle? If gradle is installed together with Android Studio that is.

Android Studio installs Gradle in a folder that looks like:
C:\Users\<username>\.gradle\wrapper\dists\gradle-7.0.2-bin\857tjihv64xamwrf0h14cai3r\gradle-7.0.2\bin
Please note that "7.0.2" is the gradle version, and this number may be different for you.
Find this path in you computer and add it to Windows "Path" environment variable. On Start Menu, type "environment variable", select "Path", click on "Edit" and add the gradle path to the list.
Restart "Command Prompt" (or PowerShell) before running cordova requirements again.

Related

Android Studio SDK manager doesn't show the candidate packages(How to install CMake)

From the post "Add C and C++ Code to Your Project",
You can install these components using the SDK Manager:
From an open project, select Tools > Android > SDK Manager
from the menu bar. Click the SDK Tools tab. Check the boxes next to LLDB,
CMake, and NDK, as shown in figure 1.
there is a image shows
But my Android Studio is not like that.
I upload a image to show my Android Studio sdk manager settings:
I googled for a while, but I didn't find anything useful. My PC is win10 64bit, I run Android Stdio 64bit, version is 2.2, I use the Android Studio bunndle version(I assume the AS and the sdk are one thing).
I also run Android Studio 2.3 on another PC, I check the sdk manager on version 2.3, it looks like behaving the same. I also try to run AS in the administrator role. it looks like behaving the same too.
The different on the AS2.2 and AS2.3 is that I can run the sdkmanager command in a win shell to install the CMake/LLDB on the PC that has AS 2.3, but I can't find the sdkmanager command in the SDK folder which is associated with the AS 2.2, so I go to download a standlone command line tools from the developer.android.com, I unzip the downloaded file and get a fold named "tool", what should I do? shold I merge the downloaded tool folder into the android_sdk/tools?
The below image is the sdk settings on another PC that has installed the AS 2.3. I installed the CMake the LLDB from the command line: "sdkmanager.bat cmake;3.6.4111459"
Why my Android Studio doesn't show the candidate not
installed packages?
Shold I merge the downloaded command line tool folder into the android_sdk/tools?

Error "Dependent package with key emulator not found" while updating Android SDK and tools

I tried to update my Android Studio and got this error. How can I fix this?
I don't have much experience with Android studio and Android app development.
I am using Android Studio 2.3 and Linux.
This worked for me as this post try: Update 2
https://stackoverflow.com/a/42735118/5133603
Update 2:
Solution to emulator package issue!
After digging in the repo's XML for a while I've spotted the issue.
It turns out that the "emulator" package is only in channel 3 (canary) while the "tools" package is in channel 0 (stable) but depends on "emulator". The solution is to force the manager to download the "emulator" package from channel 3:
./sdkmanager --channel=3 emulator
Problem solved!
This is what worked for 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-25"
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".
I hope this works for you too.
Temporarily change update channel to Canary Channel (Settings > Appearance & Behavior > System Settings > Updates). It works for me (Windows, Android Studio 2.3) I hope, this bug will be fixed in the next version of Android Studio.
My solution using Void Linux (it should fix for other distributions too):
Create a new folder named Sdk in this exact path. Bash example: $ mkdir $HOME/Android/Sdk
cd to this folder, and download the latest SDK command line version. Bash example: $ curl https://dl.google.com/dl/android/studio/ide-zips/2.3.0.8/android-studio-ide-162.3764568-linux.zip
Extract the android-studio-ide-162.3764568-linux.zip. It must be this way: $HOME/Android/Sdk/tools
Launch Android Studio, and then proceed with normal installation.
PS: If you don't have a Android folder on your $HOME, you should create it, and then make the steps 1, 2, and 3, select the $HOME/Android/Sdk Folder in Android Studio → Configure → *SDK Manager → Edit, and proceed to step 4.
Start "Android SDK Manager" from this path:
%Android_home%\SDK Manager.exe
Install all updates from this manager.
P.S. This worked for me.
This is what worked:
Download the command line tools and place them in the SDK folder (on mac:~/Library/Android/sdk).
Install Android studio 2.3 (on mac: /Application/Android Studio.app)
Add path to java in Android Studio (export PATH=/Applications/Android Studio.app/Contents/jre/jdk/Contents/Home/bin:$PATH)
Set JAVA_HOME (export JAVA_HOME=/Applications/Android Studio.app/Contents/jre/jdk/Contents/Home)
cd to ~/Library/Android/sdk/tools/bin and execute ./sdkmanager "platforms;android-25"
Accept the license - this will install the android-25 platform
Launch Android Studio, and goto the SDK Manager. The SDK Manager will now recognize the SDK path (~/Library/Android/sdk).
Now install the rest of the tools.
This fixed it for me (on a fully-patched Ubuntu 16.04 (Xenial Xerus)).
Disclaimer: I cleaned up everything beforehand:
rm -Rf ~/android-studio/ ~/.AndroidStudio2.2/ ~/.android/ ~/Android/
Then:
wget https://dl.google.com/dl/android/studio/ide-zips/2.3.0.8/android-studio-ide-162.3764568-linux.zip
wget https://dl.google.com/android/repository/tools_r25.2.3-linux.zip
unzip android-studio-ide-162.3764568-linux.zip -d ~/
mkdir -p ~/Android/sdk
unzip tools_r25.2.3-linux.zip -d ~/Android/sdk
~/Android/sdk/tools/bin/sdkmanager "platforms;android-25"
~/Android/sdk/tools/bin/sdkmanager --channel=3 emulator
~/android-studio/bin/studio.sh
Click "Configure" in the launch window
Select "SDK Manager" in the menu
The list on the right shows "partially installed" for API level 25
Click "Edit" on the right of "Android SDK Location"
You get the warning "an existing Android SDK was detected wizard will only download missing or outdated SDK components"
Click "Next"
Click "Next"
[wait while it installs]
Click "Finish"
I got this problem since hours on my Apple M1 processor.
After a clean delete of Android SDK, this workaround worked for me: https://stackoverflow.com/a/69868954/6809733
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. Worked for me!
Just delete the directory C:/Users/%user%/AppData/Local/Android/sdk and rename the other directory in that location from sdk1 to sdk.
Restart Android Studio (close projects) and an assistant will pop-up asking you to update the sdk which will be detected during that process, so a re-download won't be necessary.

Setting Android Studio's GRADLE_HOME

I installed Android Studio on Linux Mint 17.2, but when I open up a terminal window and echo $GRADLE_HOME, nothing is set. Should it be set? If it should be, how would I find where it is located so I can manually set it myself?
Thx
The Gradle installed via Android Studio will only be available only within Android Studio. I may be wrong here, since I never used Android Studio. However, if you want Gradle available outside of Android Studio you may have to install manually. Check out the Gradle Documentation. Once you installed set the Gradle home in /etc/environment file (There are several files in which you can set this, but this is my preference since it makes the variable available to all users). Add the installation location to that file. You may choose to install in a different location.
GRADLE_HOME=/usr/local/gradle-2.13
After you add add bin location to PATH variable. Eg:
PATH=...:$GRADLE_HOME/bin
Since you are adding the GRADLE_HOME in /etc/environment file you may have to restart your PC after adding.
The Android Studio zip bundles gradle. After unpacking the zip it is located in android-studio/gradle/gradle-x.x/bin (assuming the unpack directory is android-studio). In my case with Android Studio 3.1 the gradle version was gradle-4.4
so setting GRADLE_HOME to /path/to/unpackdir/gradle/gradle-4.4 should work.
Then add $GRADLE_HOME/bin to your path and you should be set.
You might have to chmod +x gradlew (for example if you use cordova and want to install a plugin)

Location of gradle binary on Android Studio Install (Linux)

Where does a standard Android Studio install under linux place the gradle executable?
I want to run it from the cmd line, but can't find it to add to my PATH
By default Android Studio uses a Gradle wrapper. You can find the gradlew file in the project root. Check this link
If you want you can install your own Gradle version and use it by command line. In that case you can tell Android Studio to use that version instead of the wrapper

How to set gradle home while importing existing project in Android studio

How to set gradle home while importing existing project in Android studio. While trying to import I need to set up this path.
The gradle plugin (which contains a bundled version of gradle) should be already installed in where/you/installed/android-studio/plugins/gradle so you shouldn't need to manually download it. Depending on the version of Android Studio, that last directory may be where/you/installed/android-studio/gradle/gradle-x.y.z (x.y.z is the version, so check your filesystem for the exact path).
If you intend on doing gradle development outside Android Studio or want a different version, you can download it separately and point it at that path, but if you only want to get Android Studio working with the bundled version, this path should do it.
For Mac OS, you can use the following -
/usr/local/opt/gradle/libexec/ or more generically - path/to/gradle/libexec/ - this is recommended. (the first path is what's achieved after installing gradle via Homebrew)
/path/to/android/studio/plugins/gradle - I don't recommend this because this version of Gradle might be out of date, and Android Studio itself might say it's incompatible.
You should be able to find it in C:\Program Files\Android\Android Studio\Gradle\Gradle 2.2.1. This is running Windows 7 64-Bit. Android Studio 1.0.2.
OSX (Less han two minutes)
Open terminal
Check if Gradle installed gradle --version, if so, goto step 4
If not brew install gradle and Goto step 2
Copy /usr/local/opt/gradle/libexec/
Paste it in Import Project Window in Android Studio > Gradle Home
Important, Celebrate!
Download Gradle http://www.gradle.org/downloads
Install
Set Gradle home to the install directory
On Linux run: whereis gradle.
For me it was /usr/lib/gradle/1.10.
I ran into same problem. I selected location C:\Program Files (x86)\Android\android-studio\plugins\gradle as Gradle Home
In Ubuntu 14.04 after $ sudo apt-get install gradle
I've got
$ whereis gradle
gradle: /usr/bin/gradle /usr/bin/X11/gradle /usr/share/gradle /usr/share/man/man1/gradle.1.gz
The path to Gradle was /usr/share/gradle
For Mac,
/Applications/Android Studio.app/Contents/gradle/gradle-3.2
Download Gradle as described above, but make sure you download version 1.9 and not the current release (1.11). I just had the same problem and downloaded the current release only to have Android Studio tell me it wasn't supported.
On Arch Linux I could not find it, so I added:
echo $APP_HOME
to /usr/bin/grade (found over which gradle)
The Install dir for me was /usr/share/java/gradle/
For migrating from eclipse to android studio
(Do not need to specify the Gradle home.)
Locate the project you exported from Eclipse, expand it, select the build.gradle file and click OK.
In the following dialog, leave Use gradle wrapper selected and click OK.
Try this for windows users
http://blog.blundell-apps.com/setting-up-android-studio-gradle-windows-7/
I tried byteit101's solution but whether I chose android-studio-path/plugins/gradle or android-studio-path/plugins/gradle/lib the IDE said it isn't correct.
Then I changed the gradle home to android-studio-path/gradle/gradle-x.x.x and it works.
Mac OSX / Linux
Step 1: Open terminal :)
Step 2: Open .bash_profile in vim to edit:
> vi ~/.bash_profile
Step 3: Add line:
> export GRADLE_HOME=/usr/local/opt/gradle
(for me it was this location, it can be different for u)
Step 4: Add line:
> export PATH="$PATH:$GRADLE_HOME/bin"
(to export bin directory of gradle)
Step 5: Verify by reopening the terminal or new tab, and check by echoing:
> echo $GRADLE_HOME
On Linux Mint 17 it was
/usr/share/gradle
for me
If you are on a Windows machine, go to the directory:
C:\Program Files\Android\Android Studio\gradle\
Click the gradle-4.4 folder from Android Studio\File\Settings, and then click the Apply button.
This is my solution on AndroidStudio/Idea for Mac
$ env | grep GRADLE
GRADLE_HOME=/usr/local/Cellar/gradle/2.6
GRADLE_USER_HOME=/Users/leon/.gradle
I used umake to install android studio. For me the path was
/home/user/.local/share/umake/android/android-studio/gradle/gradle-2.14.1
I had to use this
"C:\Program Files\Android\Android Studio\gradle\gradle-4.1"
Change the version if you have a different one.
I am using Lubuntu, I ended up finding it in :
/usr/share/gradle
Don't need to download or specify anything...
Just go to the install Android Studio plugins Path and search for any file like gradle-wrapper-x.xx.jar (x.xx = version number). Copy it to a subfolder of your project root folder named : gradle.
Example :
- file found gradle-wrapper-1.12.jar in plugins folder of Android Studio Install's path
- my project was on D:\android_repo\myProject
- created a folder into D:\android_repo\myProject\gradle
- copy gradle-wrapper-1.12.jar to this folder D:\android_repo\myProject\gradle
- import again my project and no more question about gradle.
In Windows
..\AndroidStudio2.0Beta6\android-studio\gradle\gradle-2.10
I've stumble across this question, trying to build an Ionic + Cordova app using Gradle from Android Studio installation, rather that installing Gradle separately.
On Centos, the Gradle binary was here: /home/YOURUSERNAME/.gradle/wrapper/dists/gradle-VERSION-all/CUSTOM_HASH/gradle-VERSION/bin
So, I've added export PATH=/home/maxim/.gradle/wrapper/dists/gradle-4.1-all/bzyivzo6n839fup2jbap0tjew/gradle-4.1/bin:$PATH to my ~/.bashrc and ionic cordova run android command worked just fine.
If you are on windows machine, go to the directory C:\Program Files\Android\Android Studio\gradle\ and click the gradle folder and apply it on
This worked.
C:\Program Files\Android\Android Studio\gradle\gradle-3.2
If you're using MacPorts gradle's home is:
/opt/local/share/java/gradle
For Ubuntu default version is /usr/lib/gradle/default.
In case of update, you don't need to reassign link in idea/studio.
For OSX, if going to Finder, navigate to this category: /usr/local/opt/ if you do not see gradle folder, install your grandle version manually:
https://services.gradle.org/distributions/gradle-5.4.1-all.zip
https://services.gradle.org/distributions/gradle-4.4.1-all.zip
If you are looking for specific Gradle version, simply change the version number from the zip links above, unzip and add that in the Gradle folder /usr/local/opt/gradle
If you are on a Windows machine, gradle home is located inside the installation folder of your Android Studio, usually at:
C:\Program Files\Android\Android Studio\gradle\gradle-5.1.1
Change the version if you have a different one.
On Windows it was
C:/Android Studio/jre

Resources