代码之家  ›  专栏  ›  技术社区  ›  Mohsen Mirhoseini

Firebase应用程序发行版找到了此变体的多个输出文件

  •  0
  • Mohsen Mirhoseini  · 技术社区  · 6 年前

    我添加的“Firebase应用程序分发”基于 Google document 我的Android应用程序,但运行后 appDistributionUploadRelease Gradle task我收到以下错误消息:

    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 我应该设置,但仍然没有成功。

    0 回复  |  直到 6 年前
        1
  •  6
  •   Mohsen Mirhoseini    6 年前

    在对Firebase App distribution 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
                    }
                }
            }
        }
    }
    

    注意:您必须一个接一个地执行组装和应用程序分发上载梯度任务:

    ./gradlew assembleerelease appDistributionPloadRelease

        2
  •  0
  •   kingston    5 年前

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

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

    我正在使用这个版本 2.1.2

    推荐文章