Skip to content

App Distribution Plugin configuration does not respect build types #5694

Open
@safu9

Description

@safu9

[REQUIRED] Step 2: Describe your environment

  • Android Studio version: Hedgehog 2023.1.1 Patch 2
  • Firebase Component: App Distribution Gradle Plugin
  • Component version: 4.0.1
  • Android Gradle Plugin version: 8.2.2
  • Gradle version: 8.2

[REQUIRED] Step 3: Describe the problem

Steps to reproduce:

My application uses different projects and service credential files for each build type, like this

// build.gradle.kts
buildTypes {
    getByName("release") {
        // ...
        firebaseAppDistribution {
            artifactType = "APK"
            groups = "testers"
            serviceCredentialsFile = "$rootDir/secrets/app-distribution-release-key.json"
        }
    }
    getByName("debug") {
        // ...
        firebaseAppDistribution {
            artifactType = "APK"
            groups = "testers"
            serviceCredentialsFile = "$rootDir/secrets/app-distribution-debug-key.json"
        }
    }
}

When I try to distribute with the relase config, the app distribution plugin uses the dubeg credential instead of the release one.

$ ./gradlew assembleRelease appDistributionUploadRelease

> Task :app:appDistributionUploadRelease
Using APK path in the outputs directory: ...\app\build\outputs\apk\release\app-release.apk.
Uploading APK to Firebase App Distribution...
Using service credentials file specified by the serviceCredentialsFile property in your app's build.gradle file: ...\secrets\app-distribution-debug-key.json
Uploading the APK.

> Task :app:appDistributionUploadRelease FAILED

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':app:appDistributionUploadRelease'.
> App Distribution halted because it had a problem uploading the APK: [403] The caller does not have permission

After I found this #5651 (comment) , I tried both adding import com.google.firebase.appdistribution.gradle.firebaseAppDistribution and using configure<com.google.firebase.appdistribution.gradle.AppDistributionExtension> instead of firebaseAppDistribution.
The latter worked, but the former did not.

When I went to the declaration of firebaseAppDistribution, Android Studio showed me that the extension function for org.gradle.api.Project in this code was used in my gradle script.

// IntelliJ API Decompiler stub source generated from a class file
// Implementation of methods is not available

package com.google.firebase.appdistribution.gradle

public fun com.android.build.api.dsl.ProductFlavor.firebaseAppDistribution(action: com.google.firebase.appdistribution.gradle.AppDistributionExtension.() -> kotlin.Unit): kotlin.Unit { /* compiled code */ }

public fun org.gradle.api.Project.firebaseAppDistribution(action: com.google.firebase.appdistribution.gradle.AppDistributionExtension.() -> kotlin.Unit): kotlin.Unit { /* compiled code */ }

public fun org.gradle.nativeplatform.BuildType.firebaseAppDistribution(action: com.google.firebase.appdistribution.gradle.AppDistributionExtension.() -> kotlin.Unit): kotlin.Unit { /* compiled code */ }

I think we need an extension function for com.android.build.api.dsl.ApplicationBuildType, which is not a subclass of org.gradle.nativeplatform.BuildType.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions