【问题标题】:Getting gradle exception after updating to com.google.gms:google-services:3.0.0更新到 com.google.gms:google-services:3.0.0 后出现 gradle 异常
【发布时间】:2017-02-04 16:04:09
【问题描述】:

昨天,我将我的 google services gradle 插件更新为:

dependencies {
        classpath 'com.android.tools.build:gradle:2.2.0'
        classpath 'com.google.gms:google-services:3.0.0'
    }

在那之后,我的 devDebug 风味构建中出现以下错误:

Error:org.gradle.api.GradleException: No matching client found for package name 'com.example.android.dev'

这是我的应用级别build.gradle文件的相关部分:

defaultConfig {
        applicationId 'com.example.android'
        multiDexEnabled true
        minSdkVersion 16
        targetSdkVersion 24
        versionCode 47
        versionName "1.3.2"
        signingConfig signingConfigs.myConfig
        renderscriptTargetApi 24
        renderscriptSupportModeEnabled true
    }
    buildTypes {
        debug {
            applicationIdSuffix = ".dev"
            resValue "string", "app_name", "example-debug"
        }
        release {
            minifyEnabled false
            shrinkResources false
            resValue "string", "app_name", "example"
            signingConfig signingConfigs.myConfig
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
    productFlavors {
        dev {
            // dev utilizes minSDKVersion = 21 to allow the Android gradle plugin
            // to pre-dex each module and produce an APK that can be tested on
            // Android Lollipop without time consuming dex merging processes.
            minSdkVersion 21
        }
        prod {
            // The actual minSdkVersion for the application.
            minSdkVersion 16
        }
    }

此错误不会出现在我的 prodRelease 产品风味版本中。我该如何解决?

【问题讨论】:

  • 您的调试版本与生产版本的应用程序 ID 不同。在 Firebase 控制台中添加具有该应用 ID 的 Android 应用并获取新的配置 JSON。
  • @EugenPechanec 如果我使用调试构建应用程序 ID 注册,它是否适用于所有构建类型和风格?
  • google-services.json 将包含下载时来自控制台的所有信息,所以是的。
  • @EugenPechanec 澄清一下,现在我的应用程序使用包名com.example.android 注册,我的调试版本使用包名com.example.android.dev。所以我应该在 Firebase 控制台中使用调试构建包名称注册我的应用程序,对吧?

标签: android firebase build.gradle android-productflavors android-build-type


【解决方案1】:

在 console.developers 上重新注册您的密钥

【讨论】:

  • 这是什么意思?
  • Amit Tiwari 在一分钟前澄清了我的帖子详情。
【解决方案2】:

在您的调试构建类型中,您正在使用此包:

 debug {
        applicationIdSuffix = ".dev"
    }

这条消息

找不到与包名称“com.example.android.dev”匹配的客户端

表示您的google-services.json不包含此包。

按照以下步骤操作:

  • 转到 Firebase 控制台
  • 添加另一个注册这个包的安卓应用
  • 再次导出google-services.json

【讨论】:

    【解决方案3】:

    终于解决了这个问题。

    诀窍是使用调试包名称和调试SHA1 指纹向Firebase 控制台添加另一个应用程序。

    这样做实际上会创建 2 个应用程序,但从任何应用程序下载的 google-services.json 文件包含有关这两个应用程序的信息。

    【讨论】:

      猜你喜欢
      • 2017-11-14
      • 2019-06-23
      • 1970-01-01
      • 1970-01-01
      • 2018-09-25
      • 2020-11-13
      • 1970-01-01
      • 2017-04-18
      • 2016-09-18
      相关资源
      最近更新 更多