带有apk拆分的Firebase应用程序分发无法找到apk [英] Firebase App Distribution with apk splits unable to find apk
问题描述
我正在尝试简化Firebase应用程序分发以与APK拆分一起使用.我几乎拥有它,但是我的问题是这个
I'm trying to bend firebase app distribution to work with apk splits. I almost have it, however my issue is this
Could not find the APK. Make sure you build first by running ./gradlew assemble[Variant],
or set the apkPath parameter to point to your APK
我的任务
task firebaseAllEnvRelease() {
group = "publishing"
dependsOn ordered(
":printVersionCode",
":foo:app:assembleAllRelease"
":foo:app:firebasePublishAllEnvRelease")
}
无论出于何种原因,firebase任务都会在组装之前先运行apk检查(而不是上传),因此显然apk不存在-如何强制它遵守任务的顺序?
For whatever reason, the firebase task runs the apk check (not upload) beforehand, before assemble, so obviously the apk is not there -- how can I force it to respect the order of tasks?
我知道gradle会创建任意喜欢的任务图,但是我确实有实用程序 ordered
可以通过 mustRunAfter
链接它们并且肯定是正确的.
I know gradle creates the tasks graph hopwever it likes, but I do have a utility ordered
for what, which chains them via mustRunAfter
and it is for sure correct.
方案b是在此之前在单独的gradlew命令中运行汇编,该命令有效,但是-为什么:/
Plan b is to run the assemble ina separate gradlew command before that, that works but -- why :/
推荐答案
问题是gradle插件
The problem is that the gradle plugin
-
不会声明对
assemble
任务的依赖关系(通常,无论apk拆分如何,按照gradle约定,您都不应该只是期望" apk在那里)
doesn't declare dependency on
assemble
task (in general, regardless of apk splits, by gradle convention, you shouldn't just "expect" the apks to be there)
不会按apk拆分生成任务-但您可以生成口味
doesn't generate tasks per apk splits -- but you do for flavors
这是解决方法:
// 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()}"
}
}
}
这篇关于带有apk拆分的Firebase应用程序分发无法找到apk的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!