1

我有一个 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-debugFirebase 项目。GOOGLE_APPLICATION_CREDENTIALS环境变量设置为myapp-debugFirebase 项目的服务帐号 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

所以,我对这里可能出现的问题感到困惑appIdconfig在block里面的作用是什么firebaseAppDistribution?⁉️


作为参考,这里是每个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.
4

1 回答 1

4

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

我的错误是,根据文档appId它指的是mobilesdk_app_id,而不是project_id我使用的 Firebase 。

请参阅下面的简化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"
            }
         }
      }
   ]
}

因此,解决方法是使用块中的mobilesdk_app_id值。appIdfirebaseAppDistribution

    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"
        }
    }
于 2020-05-27T15:52:34.313 回答