6

我正在将基于Google 文档的“Firebase App Distribution”添加到我的 Android 应用程序中,但在运行appDistributionUploadReleaseGradle 任务后,我收到以下错误消息:

10:18:03 PM: Executing task 'appDistributionUploadRelease'...

Executing tasks: [appDistributionUploadRelease] in project C:\Users\mohsenoid\development\***\***-Android


> Task :app:appDistributionUploadRelease FAILED

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':app:appDistributionUploadRelease'.
> App Distribution found more than 1 output file for this variant. Please contact firebase-support@google.com for help using APK splits with App Distribution.

* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.

* Get more help at https://help.gradle.org

Deprecated Gradle features were used in this build, making it incompatible with Gradle 6.0.
Use '--warning-mode all' to show the individual deprecation warnings.
See https://docs.gradle.org/5.4.1/userguide/command_line_interface.html#sec:command_line_warnings

BUILD FAILED in 19s
1 actionable task: 1 executed
10:18:23 PM: Task execution finished 'appDistributionUploadRelease'.

仅供参考,我的应用根据不同的 ABI 拆分了输出 APK:

splits {
    // Configures multiple APKs based on ABI.
    abi {
        // Enables building multiple APKs per ABI.
        enable true

        // By default all ABIs are included, so use reset() and include to specify that we only
        // want APKs for x86, armeabi-v7a, and mips.
        reset()

        // Specifies a list of ABIs that Gradle should create APKs for.
        include "armeabi-v7a", "arm64-v8a"

        // Specifies that we want to also generate a universal APK that includes all ABIs.
        universalApk true
    }
} 

我想这就是为什么这个插件对上传哪个 APK 感到困惑的原因。

以下是构建后创建的 apk 列表:

app-arm64-v8a-release.apk
app-armeabi-v7a-release.apk
app-universal-release.apk

更新:

我浏览了插件源代码并注意到有一个未记录的属性apkPath,我应该设置它,但仍然没有成功。

4

2 回答 2

6

在对 Firebase App 分发 jar 文件进行反编译和逆向工程并阅读代码后,我找到了这个解决方案:

applicationVariants.all { variant ->
    variant.outputs.each { output ->
        // Filter is null for universal APKs.
        def filter = output.getFilter(OutputFile.ABI)

        if (filter == null) {
            tasks.findAll {
                it.name.startsWith(
                        "appDistributionUpload${variant.name.capitalize()}")
            }.each {
                it.doFirst {
                    it.appDistributionProperties.apkPath = output.outputFile.absolutePath
                }
            }
        }
    }
}

注意:你必须一个接一个地执行 assemble 和 app 分发上传 Gradle 任务:

./gradlew assembleRelease appDistributionUploadRelease

于 2019-10-07T11:58:20.137 回答
0

我通过设置 apkPath 解决了这个问题:

firebaseAppDistribution {
    artifactPath="$rootDir/app/build/outputs/apk/...etc...[universal].apk"
    serviceCredentialsFile="..."
    testers="user@company.com"
}

我正在使用版本2.1.2

于 2021-06-18T08:11:32.770 回答