android studio setting env variable PATH - android-studio

Is there a way to change the environment variable PATH for building within Android Studio?
For command line builds, I set the PATH and run the gradle command. The build succeeds.
If I try to build from within android studio, the build fails, most likely because the build within Android Studio doesn't use the PATH

Related

Is gradle installed with Android Studio on Windows?

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.

Android Studio ignores GRADLE_USER_HOME?

I have Windows environment variables assigned
GRADLE_HOME=C:\Tools\gradle
GRADLE_OPTS=-Dgradle.user.home=C:/Tools/gradle
GRADLE_USER_HOME=c:\Tools\gradle
When running gradlew build from command line, all project dependencies are loaded to C:\Tools\gradle.
But if I make build from Android Studio, gradle uses C:\Users\MyUserName\.gradle directory.
AS bug?

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

Trying to run App in Android studio 1.4.1 and having build problems

Go to run my app and i get the following errors in the log.
Error:Could not run build action using Gradle installation 'C:\Program Files\Android\Android Studio\gradle\gradle-2.4'.
Log states the following "Gradle sync failed: Could not run build action using Gradle installation 'C:\Program Files\Android\Android Studio\gradle\gradle-2.4'.
Consult IDE log for more details (Help | Show Log)"
Would anyone kindly tell me how to rectify this problem.
There are two options for you
option 1-update the gradle:
i-Get latest version supported by Android Studio from: http://www.gradle.org/downloads
ii-Extract the gradle file and install to dists folder(gradle folder): default location is: C:\Users[username]\gradle\wrapper\dists
iii-Open Android Studio: File/Settings/Gradle/Service directory path: (Change to folder you set above) and Click ok.
iv-restart Android Studio.
Option 2-Delete the .gradle folder:
default location is:
C:\Users[username]\gradle\wrapper\dists
after that open Android Studio and make a new project (might need to restart).

Resources