升级到gradle 3.3之后,有一些api不能用了,影响比较大的可能就是之前的修改打包apk路径
修改之后:
/Gradle3.3 以上的方法/
applicationVariants.all { variant ->
if (variant.buildType.name != "debug") {
variant.getPackageApplicationProvider().get().outputDirectory = new File(project.rootDir.absolutePath + "/apk")
}
variant.getPackageApplicationProvider().get().outputScope.apkDatas.forEach { apkData ->
apkData.outputFileName = ((project.name != "app") ? project.name : rootProject.name) + "-" +
variant.versionName + "_" +
variant.flavorName + "_" +
variant.buildType.name + "_" +
".apk"
}
}
3.3之前的修改方式:
applicationVariants.all { variant ->
if (variant.buildType.name != "debug") {
variant.getPackageApplication().outputDirectory = new File(project.rootDir.absolutePath + "/apk")
}
variant.getPackageApplication().outputScope.apkDatas.forEach { apkData ->
apkData.outputFileName = ((project.name != "app") ? project.name : rootProject.name) + "-" +
variant.versionName + "_" +
variant.flavorName + "_" +
variant.buildType.name + "_" +
".apk"
}
}
3.0之前的方式:
applicationVariants.all { variant ->
//这个修改输出的APK路径
if (variant.buildType.name != "debug") {//防止AS无法安装debug包(apk)
variant.getPackageApplication().outputDirectory = new File(project.rootDir.absolutePath + "/apk")
}
variant.getPackageApplication().outputScope.apkDatas.forEach { apkData ->
//这个修改输出APK的文件名
apkData.outputFileName = "AppName-" +
variant.versionName + "_" +
apk_time + "_" +
variant.flavorName + "_" +
variant.buildType.name + "_" +
variant.signingConfig.name +
".apk"
}
}
参考地址:http://blog.csdn.net/angcyo https://blog.csdn.net/angcyo/article/details/78357512
网友评论