2016-11-29 146 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工作室工作的經理。

確實做到了其他用戶提供獨立的工具提示,但沒有運氣