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
Add a comment
|
1 Answer
Update 1 - Easy way for windows
set environment
- Set
GRADLE_USER_HOMEasD:\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
6 Comments
neonidian
Editing 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 documentationBurhan Khanzada
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 homeneonidian
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 from Gradle documentation.neonidian
The GRADLE_USER_HOME can also be got when you enable the debug flag. E.g.,
gradlew <task> --debugBurhan Khanzada
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 |