FirebaseAppDistribution:appDistributionUpload gradle 命令中缺少应用 ID

Gab*_*tti 2 android firebase android-gradle-plugin firebase-app-distribution

我正在使用带有 Gradle 插件的 Firebase 应用分发。
当我尝试运行appDistributionUploadDebug命令时,我收到错误:

Getting appId from output of google services plugin

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':app:appDistributionUploadDebug'.
> Missing app id
Run Code Online (Sandbox Code Playgroud)

我在build.gradle文件中包含了插件

   dependencies {
        classpath 'com.google.firebase:firebase-appdistribution-gradle:1.2.0'
    }
Run Code Online (Sandbox Code Playgroud)

然后我添加了配置:

apply plugin: 'com.android.application'
apply plugin: 'com.google.firebase.appdistribution'

android {
   //...
        debug {
            firebaseAppDistribution {
                serviceAccountCredentials = "/path/to/your-service-account-key.json"
                releaseNotesFile="/path/to/releasenotes.txt"
                testers="email@example.com"
            }
        }
}
Run Code Online (Sandbox Code Playgroud)

Gab*_*tti 8

如果您没有在项目中使用google services gradle 插件,则必须appId配置中添加该属性。

就像是:

            firebaseAppDistribution {
                // Firebase App Distribution setup
                appId = "...."  //<-- add your appID

                serviceAccountCredentials = "/path/to/your-service-account-key.json"
                releaseNotesFile="/path/to/releasenotes.txt"
                testers="email@example.com"
            }
Run Code Online (Sandbox Code Playgroud)

您可以appIdgoogle-services.json文件中找到值

{
  ...
  "client": [
    {
      "client_info": {
        "mobilesdk_app_id": "...",//<-- YOU NEED THIS APP_ID
        "android_client_info": {
          "package_name": "..."
        }
      },
     
  ...
}
Run Code Online (Sandbox Code Playgroud)

或在 Firebase 控制台中的项目设置页面 -> 常规选项卡。