我有一個項目使用Google Firebase消息。我遵循了文檔,它像一個魅力。問題是,要建立在服務器上,我需要manualy添加.aar文件,所以我查了gradle這個依賴關係樹,並添加所需的依賴關係圖所示:Firebase雲消息傳遞錯誤:包名稱不止一個庫'com.google.android.gms'
火力的消息依賴
的問題是,當我嘗試編譯,我得到以下錯誤:
Error: more than one library with package name 'com.google.android.gms'
錯誤消息:
我檢查了有關此錯誤的其他線程在stackoverflow中,但沒有解決方案爲我工作。下面是我的gradle這個文件的依賴關係:
dependencies {
debugCompile project(path: ':OrbitEmailCore', configuration: 'debug')
releaseCompile project(path: ':OrbitEmailCore', configuration: 'release')
debugCompile project(path: ':OrbitInterOp', configuration: 'debug')
releaseCompile project(path: ':OrbitInterOp', configuration: 'release')
compile 'commons-io:commons-io:2.0.1'
compile files('./libs/docviewer_v4.jar')
compile 'com.android.support:cardview-v7:22.0.0'
compile 'com.android.support:recyclerview-v7:22.0.0'
testCompile 'junit:junit:4.12'
testCompile 'org.powermock:powermock-module-junit4:1.6.4'
testCompile 'org.powermock:powermock-mockito-release-full:1.6.4'
testCompile 'org.powermock:powermock-api-mockito:1.6.4'
compile project(':firebase-iid-9.8.0')
compile project(':firebase-messaging-9.8.0')
compile project(':firebase-common-9.8.0')
compile project(':play-services-basement-9.8.0')
}
我知道,當使用不同版本的依賴關係,這個問題usally出現,但對我來說,我使用9.8.0爲他們所有。問題在於play-service-basement的依賴性,但是如果我不添加它,我的代碼將無法編譯,因爲某些類缺失。
奇怪的是,我的項目中的外部庫文件夾包含9.0和9.8版的firebase和play-services的庫,即使我沒有在項目中的任何其他位置聲明它們。
誰能幫助?
問題是我使用不同的風味,所以我的依賴項在主項目中,然後我爲每種風味使用google-services.json。因此,我在應用插件:'com.google.gms.google-services' line dded line在每個flavor版本結束時,但它沒有檢測到依賴項的存在,因爲它在主版本中聲明.gradle文件 – user2751809
我在最後使用apply插件行添加了play-services-basement依賴關係到flavor gradle,但仍然有相同的錯誤。 如果我刪除了「apply plugin」這一行,那麼錯誤消失,但我無法獲得註冊令牌或接收消息。 – user2751809