I want to use custom path for .gradle
folder instead of $USER_HOME/.gradle
because i am already developing android apps and changed this path to custom path from which it does not affect if whenever i install new windows so i can save me from downloading all that files and different version of gradle wrapper again and again so when now i start learning flutter i realize that its always creating that folder in my $USER_HOME/.gradle
directory and there is no option in flutter to change this behavior and i also tried to open the android folder of flutter project from android studio and try to change the path from there but this doesn't help either
Asked
Active
Viewed 4,958 times
4

Burhan Khanzada
- 945
- 9
- 27
1 Answers
1
Update 1 - Easy way for windows
set environment
- Set
GRADLE_USER_HOME
asD:\gradle\.gradle
Solution for this is to add this line set GRADLE_USER_HOME=(D:\android\.gradle or your custom path) // remove that brackets
in android\gradlew.bat
file at the first line and that's it now you can use your old gradle download files

Burhan Khanzada
- 945
- 9
- 27
-
1Editing gradlew.bat file is not a good practice since it is a wrapper file and when you upgrade your Gradle wrapper this change would not be retained. Instead, create a `gradle.properties` file in the project's root directory and set a system property `gradle.user.home=(path to directory)`. See [Gradle documentation](https://docs.gradle.org/current/userguide/build_environment.html#sec:gradle_system_properties) – neonidian May 15 '20 at 19:06
-
can you please elaborate your comment further because when I use `gradle.user.home=D:\\android\\.gradle` in `gradle.properties` it's not working its creating `.gradle` directory in the default directory of user home – Burhan Khanzada May 15 '20 at 22:03
-
Do you have any other gradle.properties file defined on the command line or in the .gradle directory in user's home directory. If so, `gradle.user.home` property set in those property files will override the value in gradle.properties in project directory. See [how gradle properties file picks up the values](https://docs.gradle.org/current/userguide/build_environment.html#sec:gradle_configuration_properties) from Gradle documentation. – neonidian May 17 '20 at 17:00
-
The GRADLE_USER_HOME can also be got when you enable the debug flag. E.g., `gradlew
--debug` – neonidian May 17 '20 at 17:01 -
no, I haven't defined any file even I have deleted the default `.gradle` folder from my home directory or probably I am not setting the path format correctly but I have searched this should be a valid format in windows – Burhan Khanzada May 17 '20 at 17:41
-
https://stackoverflow.com/questions/56350799/gradle-user-home-set-in-gradle-properties-build-gradle-or-settings-gradle-to check this post to to know more on this problem – Burhan Khanzada Oct 18 '20 at 15:40