无法构建同时包含 Azure SDK 和 Google Play 的应用

Cannot build app containing both Azure SDK and Google Play

我很清楚 Android 中 app:dexDebug 错误背后的原因。在Whosebug中翻了很多类似的问题,尝试了所有可能的解决方案,我终于找到了错误的原因。以下是我的依赖项:

如果两次编译

compile 'com.google.android.gms:play-services:+'
compile 'com.microsoft.azure:azure-mobile-services-android-sdk:2.0.3'

一起编译,错误导致。删除任何一个编译都会删除错误,但我不明白为什么? Google 云消息传递需要 Play,而将设备注册到 Azure 推送通知中心需要 Azure 服务。我看不出他们共享公共 jar 文件或在任何地方有 repeated/duplicate class 的任何可能性。

libs 文件夹是空的。

对这个问题有什么建议吗?

你不应该使用版本号而不是“+”吗?

试试这个:

compile 'com.google.android.gms:play-services:8.1.0'

因为“+”可能会同时编译 2 个导入....

编辑:您的错误跟踪到底是什么?

Googleplay服务和azure mobile service编译没有冲突。我有一个具有依赖项的测试项目: compile 'com.android.support:appcompat-v7:23.1.0' compile 'com.microsoft.azure:azure-mobile-services-android-sdk:2.0.3' compile 'com.google.android.gms:play-services:+' 并将项目与 gradle 个文件同步,在我这边工作正常。

在Azure Mobile Service中集成Notification Hubs,可以参考official guide of Azure Notification Hubs 10/15/2015更新。在这篇文章中,它使用了 gms 依赖: compile 'com.google.android.gms:play-services-base:6.5.87'

对了,我找到了一个,也许它能给你一些帮助。

好吧,实际上 play 服务和 azure 服务二进制文件都有依赖循环。要解决此问题而不是使用通用语句(即 'com.google.android.gms:play-services:8.3.0' ),请使用精确的语句(即例如 'com.google.android.gms:play-services-maps:8.3.0' ),它缩小了编译区域,从而减少了冲突的可能性。希望这有帮助