在android studio中更改gradle构建目录?

在android studio中更改gradle构建目录?

问题描述:

我刚刚安装了 Android Studio,我刚刚在学习使用 Gradle 进行构建.但是,使用默认项目设置,我的构建位于项目目录中,我希望将它们放置在其他地方(最好在项目目录之外).有可能实现这一目标吗?我在哪里进行更改以及我要进行哪些更改?

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 would like to have them placed elsewhere (preferably outside of the project directory). Is it possible to achieve this? Where do I make a change and what change do I make?

in root build.gradle

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

另见 Gradle 全局构建目录

和文档 https://gradle.org/docs/current/userguide/writing_build_scripts.html