Firebase App Distribution 无法获取应用程序信息:[400] 请求在 multi-firebase Android 项目设置中包含无效参数

Firebase App Distribution failed to fetch app information: [400] Request contains an invalid argument on multi-firebase Android project setup

我有一个 Android 应用程序,它有 2 个不同的 firebase 项目,一个用于 DEBUG 构建,一个用于 RELEASE,它们分别有自己的 google-services.json 文件。

app
|-src/main/debug
| |-google-services.json (Points to Firebase with ID: `myapp-debug`)
|-src/main/release
| |-google-services.json (Points to Firebase with ID: `myapp-release`)

我有 app/build.gradle 设置,因此 RELEASE 和 DEBUG 版本都发布到 myapp-debug Firebase 项目。 GOOGLE_APPLICATION_CREDENTIALS 环境变量设置为 myapp-debug Firebase 项目的服务帐户 JSON。

android {
    // ... more configs here
    buildTypes/debug {
        firebaseAppDistribution {
            releaseNotes = "DEBUG"
            apkPath = "/path/to/debug.apk"
            groups = "qa, devs"
        }


        buildTypes/release {
            firebaseAppDistribution {
                appId="myapp-debug" // Force release builds to same debug Firebase project
                releaseNotes = "RELEASE"
                apkPath = "/path/to/release.apk"
                groups = "qa, devs"
            }
        }
    }
}

但是,当我构建应用程序并尝试使用 appDistributionUpload* 命令发布时,我收到 RELEASE 构建错误。

./gradlew clean assembleDebug
./gradlew assembleRelease

./gradlew appDistributionUploadDebug         # This command succeeds
./gradlew appDistributionUploadRelease       # This one fails with failed to fetch app information

所以,我对这里可能出什么问题感到困惑appId config inside firebaseAppDistribution block 的作用是什么?⁉️


作为参考,这里是每个 appDistributionUpload 命令的日志。

> Task :ClassifiedsApp:appDistributionUploadDebug
Using APK path specified by the apkPath parameter in your app's build.gradle: /myapp/build/outputs/apk/debug/debug-app.apk.
Uploading APK to Firebase App Distribution...
Getting appId from output of google services plugin
Using credentials file specified by environment variable GOOGLE_APPLICATION_CREDENTIALS: ****
This APK has not been uploaded before.
Uploading the APK.
Uploaded APK successfully 202
Added release notes successfully 200
Added testers/groups successfully 200
App Distribution upload finished successfully!



> Task :ClassifiedsApp:appDistributionUploadRelease FAILED
Using APK path specified by the apkPath parameter in your app's build.gradle: /myapp/build/outputs/apk/release/release-app.apk.
Uploading APK to Firebase App Distribution...
Getting appId from build.gradle file
Using credentials file specified by environment variable GOOGLE_APPLICATION_CREDENTIALS: ****
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':ClassifiedsApp:appDistributionUploadRelease'.
> App Distribution failed to fetch app information: [400] Request contains an invalid argument.

我已经联系了 Firebase 支持团队,支持团队的 Kyle 已经回复了我。

我的错误是,根据 documentationappId 它指的是 mobilesdk_app_id,而 不是 Firebase project_id 我用过的。

请参阅下面的简化 google-services.json 文件。

{
   "project_info":{
      "project_id":"firebase-project-id"
   },
   "client":[
      {
         "client_info":{
            "mobilesdk_app_id":"1:543212345:android:93690bfb936b9c",
            "android_client_info":{
               "package_name":"app.package.name"
            }
         }
      }
   ]
}

因此,解决方法是在 firebaseAppDistribution 块中将 mobilesdk_app_id 值用作 appId

    buildTypes/release {
        firebaseAppDistribution {
            appId="1:543212345:android:93690bfb936b9c" // Force release builds to same debug Firebase project
            releaseNotes = "RELEASE"
            apkPath = "/path/to/release.apk"
            groups = "qa, devs"
        }
    }