1

“是否可以将 Firebase 应用分发与 APK 拆分一起使用?它没有声明对assemble任务的依赖,有什么解决方法吗?”

4

1 回答 1

0

gradle 插件的问题在于它

  1. 不声明对assemble任务的依赖(通常,无论 apk 拆分如何,按照 gradle 约定,你不应该只是“期望”apk 在那里)

  2. 不会为每个 apk 拆分生成任务——但你会为风味做

尝试以下解决方法:

// Generate firebase app distribution task variants for all abis
applicationVariants.all { variant ->
variant.outputs.all { output ->
def abi = output.getFilter(com.android.build.OutputFile.ABI)

if (abi == null) return
def abiName = abi.replace("_", "").replace("-", "")
task("appDistributionUpload${abiName.capitalize()}${variant.name.capitalize()}", type: com.google.firebase.appdistribution.gradle.UploadDistributionTask_Decorated) {
appDistributionProperties = new com.google.firebase.appdistribution.gradle.AppDistributionProperties(
new com.google.firebase.appdistribution.gradle.AppDistributionExtension(),
project,
variant
)
appDistributionProperties.apkPath = output.outputFile.absolutePath
appDistributionProperties.serviceCredentialsFile = project.file("secrets/ci-firebase-account.json")
appDistributionProperties.releaseNotes = abi
appDistributionProperties.groups = "ra-testers"
 
// Add dependsOn respective assemble task, so it actually
// builds apk it wants to upload, not just expect it to be there
dependsOn "assemble${variant.name.capitalize()}"
}
}
}
于 2020-08-04T15:16:39.140 回答