【问题标题】:Android Google Services Plugin IssueAndroid Google 服务插件问题
【发布时间】:2016-03-06 07:39:26
【问题描述】:

在运行 GCM Sender 应用程序时,我遇到了这种类型的异常

信息:Gradle 任务 [:app:generateDebugSources, :app:generateDebugAndroidTestSources] :app:preBuild UP-TO-DATE :app:preDebugBuild UP-TO-DATE :app:checkDebugManifest :app:preReleaseBuild UP-TO-DATE :app:prepareComAndroidSupportAppcompatV72301Library :app:preDebugAndroidTestBuild UP-TO-DATE :app:prepareComAndroidSupportMultidex101Library UP-TO-DATE :app:prepareComAndroidSupportSupportV42301库 :app:prepareComGoogleAndroidGmsPlayServicesBase830Library UP-TO-DATE :app:prepareComGoogleAndroidGmsPlayServicesBasement830Library 最新:app:prepareComGoogleAndroidGmsPlayServicesGcm830Library 最新 :app:prepareComGoogleAndroidGmsPlayServicesMeasurement830Library 最新:app:prepareDebugDependencies:app:compileDebugAidl :app:compileDebugRenderscript :app:generateDebugBuildConfig UP-TO-DATE :app:generateDebugAssets 最新 :app:mergeDebugAssets 最新 :app:generateDebugResValues UP-TO-DATE :app:processDebugGoogleServices FAILED 错误:任务执行失败 ':app:processDebugGoogleServices'。

模块根文件夹中缺少文件 google-services.json。没有它,Google 服务插件将无法运行。信息:BUILD 失败信息:总时间:2.942 秒信息:1 错误 信息:0 个警告信息:在控制台中查看完整输出

谁能解释一下

【问题讨论】:

标签: android google-cloud-messaging google-play-services


【解决方案1】:

集成 Google Play 服务的方式最近发生了变化。您必须添加 google-services.json。

在这里您将找到如何获取此配置文件以及如何集成 GCM 的信息:

https://developers.google.com/cloud-messaging/android/client

【讨论】:

  • 完成后我将尝试与视频演示一起运行应用程序。然后它显示 Build failed with the above Exception 你能发送任何工作示例吗?
  • 你应该展示你的一些代码。复制和粘贴异常不是很有帮助。你的 build.gradle 文件是什么样子的?您的 google-services.json 放在哪里。您的一般应用设置如何。
  • build.gradle(Module app) : dependencies { compile fileTree(dir: 'libs', include: ['*.jar']) compile 'com.google.android.gms:play-services :8.3.0' compile 'com.android.support:appcompat-v7:23.0.0' // 测试依赖 androidTestCompile 'com.android.support.test.espresso:espresso-core:2.1' androidTestCompile 'com.android.support .test:runner:0.2' androidTestCompile 'com.android.support:support-annotations:23.0.0' }
  • build.gradle(Project: gcm) buildscript { repositories { jcenter() } dependencies { classpath 'com.android.tools.build:gradle:1.5.0' classpath 'com.google.gms: google-services:1.5.0-beta2' // 注意:不要将应用程序依赖项放在这里;它们属于 // 在单个模块 build.gradle 文件中 } }
  • 我不明白你能解释一下我是这个 Stackoverflow 的新手
【解决方案2】:

此示例使用 Google 服务插件,它要求您在项目的 app 目录中有 google-services.json 文件。

See this documentation,一定要获取配置文件并添加到你的Android项目的app目录中。

还要确保更新 GcmSender.java 中的 API 密钥值。

【讨论】:

    【解决方案3】:

    请在您的项目应用程序 gradle 文件中添加 multiDexEnabledtrue 并结帐,

    defaultConfig {
        multiDexEnabled true
    }
    

    【讨论】:

      【解决方案4】:

      你需要:

      1-转到https://console.firebase.google.com
      2-创建一个项目。
      3-然后点击将 Firebase 添加到您的 Android 应用
      4- 添加(包名称、调试签名证书 SHA-1)
      5- 然后 Firebase 将生成 google-services.json
      6-复制此文件并将其添加到您的项目根目录
      7-然后按照每个步骤进行

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多