Change gradle build directory in android studio?

后端 未结 3 808
伪装坚强ぢ
伪装坚强ぢ 2020-12-08 16:55

I just installed Android Studio and I am just learning to build using Gradle. However, with the default project setup, my builds are located in the project directory and I w

相关标签:
3条回答
  • 2020-12-08 17:18

    The project iml file has a BUILD_FOLDER_PATH attribute. I haven't tried changing it myself yet, so not sure if it will work. The default value is $MODULE_DIR$/build.

    Edit: I did a quick test and this did not work. Once changed, the project needs to reload because the iml file changed. Upon reload it reverts the build directory to default.

    0 讨论(0)
  • 2020-12-08 17:20

    You can pass the "buildDir" property to the gradlew.bat (I'd assume you can do this in the Linux version as well but I haven't tested it)

    Example:

    gradlew.bat assembleRelease -PbuildDir="C:\BuildFolder"
    
    0 讨论(0)
  • 2020-12-08 17:36

    in root build.gradle

    allprojects {
        buildDir = "/path/to/build/${rootProject.name}/${project.name}"
    }
    

    See also Gradle global build directory

    and docs https://gradle.org/docs/current/userguide/writing_build_scripts.html

    0 讨论(0)
提交回复
热议问题