我有一个项目使用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