Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Firebase App Distribution found more than 1 output file for this variant

I am adding "Firebase App Distribution" based on Google document to my Android application but after running appDistributionUploadRelease Gradle task I get this error message:

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 [email protected] 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'.

FYI, my app has splits output APKs based on different ABIs:

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
    }
} 

and I guess that is why this plugin is confused about which APK to upload.

Here is the list of apks which are being created after build:

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

UPDATE:

I went through the plugin source code and noticed that there is an undocumented property called apkPath which I should set, but still, no success.

like image 404
Mohsen Mirhoseini Avatar asked Oct 02 '19 20:10

Mohsen Mirhoseini


1 Answers

After decompiling and reverse-engineering the Firebase App distribution jar file and reading the code I found this solution:

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
                }
            }
        }
    }
}

Note: You have to execute assemble and app distribution upload Gradle tasks one after another:

./gradlew assembleRelease appDistributionUploadRelease

like image 127
Mohsen Mirhoseini Avatar answered Oct 03 '22 22:10

Mohsen Mirhoseini