build.gradle中调整release包的路径

假设当前项目的主module是main,如果要调整release包的路径,则需要在main/build.gradle文件中添加如下代码:

不同的gradle build tools版本,使用方法不同:

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'以及之后的版本:

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

猜你喜欢

转载自blog.csdn.net/chenzhengfeng/article/details/104947592
今日推荐