2016-11-29 144 views
8

我已将Firebase添加到Android应用以推送通知。在使用之前,我已经更新了build.gradle。它的工作正常。无法更新Firebase依赖关系(com.google.firebase)

compile 'com.google.firebase:firebase-messaging:9.2.0' 

现在我已更新到最新的库,但出现错误。

dependencies { 
    //.... 
    compile 'com.google.firebase:firebase-core:10.0.1'  
    } 

我在的时候得到错误重建项目

Error:A problem occurred configuring project ':app'. Could not resolve all dependencies for configuration ':app:_debugApkCopy'. Could not find com.google.firebase:firebase-core:10.0.1. Required by: DGApp:app:unspecified

预先感谢您。

+0

检查我的回答here.http://stackoverflow.com/questions/37360126/getting-exception-java-lang-noclassdeffounderror-com- google-firebase-firebaseop/38224316#38224316它可能对您有所帮助 –

+0

您是否最近更新了您的支持库?检查此答案http://stackoverflow.com/a/39302669/3111083。 –

+0

谢谢。现在我正在将我的SDK更新到最新版本。 –

回答

4

加入谷歌服务插件

在的build.gradle文件,包括谷歌的服务插件:

buildscript { 
// ... 
dependencies { 
    // ... 
    classpath 'com.google.gms:google-services:3.0.0' 
} 
} 

然后,你的模块在摇篮文件(通常为应用程式/的build.gradle ),在该文件的底部添加的应用插件线,以使摇篮插件:

apply plugin: 'com.android.application' 

android { 
// ... 
} 

dependencies { 
// ... 
compile 'com.google.firebase:firebase-core:10.0.1' 

// Getting a "Could not find" error? Make sure you have 
// the latest Google Repository in the Android SDK manager 
} 

// ADD THIS AT THE BOTTOM 
apply plugin: 'com.google.gms.google-services' 

More details refer Firebase setup

-2

可能是你没有给出正确的回购。


             
  
repositories { 
 
    maven { url 'https://maven.fabric.io/public' } 
 
}
}
20

您必须从独立SDK管理器更新您的Google Play服务和Google存储库。

首先,开放的Android工作室,并在顶部工具栏中单击该图标:

Image

然后,当对话框启动,单击“启动独立SDK管理器”,在对话框的左下角:

image

为了让信息比我们希望得到更新/安装什么其他确保没有,点击“取消全部”:

Image

当独立SDK管理器窗口打开时,查找“Extras”并将其折叠。您应该看到“Google Play服务”和“Google Repository”,在右侧您应该看到“更新可用:{something}”。选择这些项目,然后点击“安装”。

Image

当他们完成安装,该错误会自行消失。

+0

谢谢。我更新了SDK。 –

+0

@NitinKarande是否有效?如果没有,请确保您正在更新“Google Play服务”和“Google存储库”,而不是其他SDK –

2

如果你阅读文档他们表明您更新最新Google Repository in the Android SDK manager

所以只是去Android SDK Managerinstall the latest version of below two libraries

1 - 谷歌播放服务

2,谷歌库

检查来自文件的图像:

enter image description here

0

获取“无法找到”错误?确保您在Android SDK管理器中拥有最新的Google Repository。

为了解决问题;

  • 打开SDK管理器和更新SDK工具为Android 7.0(API 24)下的最新尤其是谷歌的API
0

我只得到了它与Android SDK工作室工作的经理。

确实做到了其他用户提供独立的工具提示,但没有运气