Open safu9 opened 6 months ago
Hi @safu9, thank you for reaching out and reporting the issue. I tried reproducing the issue and I was able to replicate the issue in "firebaseAppdistribution" key when configured in "buildTypes". I’ll notify our engineers and see what we can do here.
@safu9
Thanks for reporting this issue; we're looking into what's causing this ignoring of application variants. Can you try replacing firebaseAppDistribution
with configure<AppDistributionExtension>
in both your release and debug buildTypes?
Yes, replacing firebaseAppDistribution
with configure<AppDistributionExtension>
in both buildTypes resolves this problem. Gradle uses the correct serviceCredentialsFile for each buildType when using configure<AppDistributionExtension>
.
@MaesterChestnut @lehcar09 Using configure<AppDistributionExtension>
doesn't resolve this issue when I use flavors. Uploads fail because the appDistributionUpload task will always use the last resolved json file. In my case that'd be firebase_app_distribution_key_qa.json
. For example, if I run assembleTestUATRelease appDistributionUploadTestUATRelease
, it'd throw a 403 Forbidden
error because the task uses firebase_app_distribution_key_qa.json
to upload the UAT app.
androidComponents {
val firebaseAppDistributionConfig = mapOf(
"TestPROD" to FirebaseConfig(
serviceCredentialsFile = "./vault/firebase_app_distribution_key_prod.json",
releaseNotes = "Release notes for PROD",
groups = "dev"
),
"TestUAT" to FirebaseConfig(
serviceCredentialsFile = "./vault/firebase_app_distribution_key_uat.json",
releaseNotes = "Release notes for UAT",
groups = "dev"
),
"TestQA" to FirebaseConfig(
serviceCredentialsFile = "./vault/firebase_app_distribution_key_qa.json",
releaseNotes = "Release notes for QA",
groups = "dev"
)
)
onVariants { variant ->
val variantName = variant.flavorName
val firebaseConfig = firebaseAppDistributionConfig[variantName]
firebaseConfig?.let {
configure<com.google.firebase.appdistribution.gradle.AppDistributionExtension> {
serviceCredentialsFile = it.serviceCredentialsFile
releaseNotes = it.releaseNotes
groups = it.groups
}
}
}
}
[REQUIRED] Step 2: Describe your environment
[REQUIRED] Step 3: Describe the problem
Steps to reproduce:
My application uses different projects and service credential files for each build type, like this
When I try to distribute with the relase config, the app distribution plugin uses the dubeg credential instead of the release one.
After I found this https://github.com/firebase/firebase-android-sdk/issues/5651#issuecomment-1908246234 , I tried both adding
import com.google.firebase.appdistribution.gradle.firebaseAppDistribution
and usingconfigure<com.google.firebase.appdistribution.gradle.AppDistributionExtension>
instead offirebaseAppDistribution
. 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.I think we need an extension function for com.android.build.api.dsl.ApplicationBuildType, which is not a subclass of org.gradle.nativeplatform.BuildType.