Adjust the path of the release package in build.gradle

Assuming that the main module of the current project is main, if you want to adjust the path of the release package, you need to add the following code to the main/build.gradle file:

Different versions of gradle build tools have different usage methods:

Versions before classpath'com.android.tools.build:gradle:3.3.0':

android {
  applicationVariants.all {
    def buildType = it.buildType.name
    if (buildType == "release") {
      it.getPackageApplication().outputDirectory =
              new File(project.rootDir.absolutePath + "/main/build/outputs/apk")
    }
  }
}

classpath'com.android.tools.build:gradle:3.3.0' and later versions:

android {
  applicationVariants.all {
    def buildType = it.buildType.name
    if (buildType == "release") {
      it.getPackageApplicationProvider().get().outputDirectory =
              new File(project.rootDir.absolutePath + "/main/build/outputs/apk")
    }
  }
}

 

Guess you like

Origin blog.csdn.net/chenzhengfeng/article/details/104947592