Android 如何将BaseGameUtils添加到Chrome Cast项目?

Android 如何将BaseGameUtils添加到Chrome Cast项目?,android,chromecast,Android,Chromecast,我试图在Chrome cast项目中添加一个领导板,但出现了错误。Android Studio中的Android项目。在我的gradle构建中-错误:多个程序包名为“com.google.android.gms”的库 我理解为什么您不想使用两个同名的不同库,但不确定如何在整个项目中使用相同的库。以下是gms的两种用途: 1) 主要活动依赖于“CastCompanyLibrary android master”,后者随后使用google-play-services_lib。我不确定它使用的是哪个版

我试图在Chrome cast项目中添加一个领导板,但出现了错误。Android Studio中的Android项目。在我的gradle构建中-错误:多个程序包名为“com.google.android.gms”的库

我理解为什么您不想使用两个同名的不同库,但不确定如何在整个项目中使用相同的库。以下是gms的两种用途: 1) 主要活动依赖于“CastCompanyLibrary android master”,后者随后使用google-play-services_lib。我不确定它使用的是哪个版本的gms,但版本号在清单中引用。这仅仅是为了获取他们安装在手机上的游戏服务版本吗? 2) BaseGameUtils-依赖com.google.android.gms:play services:+(我认为这是最新版本的play services,但与另一个版本不匹配

MainActivity gradle file
dependencies {
    compile project(':BaseGameUtils')
    compile fileTree(dir: 'libs', include: '*.jar')
    compile project(':CastCompanionLibrary-android-master')
}

CastCompanionLibrary-android-master dependencies {
    compile fileTree(dir: 'libs', include: '*.jar')
    compile project(':android-support-v7-appcompat')
    compile project(':android-support-v7-mediarouter')
    compile project(':google-play-services_lib')
}

BaseGameUtils dependencies {
    compile 'com.android.support:appcompat-v7:20.0.+'
    compile 'com.android.support:support-v4:20.0.+'
    compile 'com.google.android.gms:play-services:+'
}

所以,问题(我认为)这是com.google.android.gms的两个版本,但我如何纠正它,使它们都使用相同的版本。我已经使用安卓系统将近2年了,但这是我关于堆栈溢出的第一个问题。非常感谢您的帮助-是否有专家对此有答案?

似乎您已经修改了CCL si的gradle文件nce您拥有的与CCL在GitHub中拥有的不匹配。最好的方法是只使用您需要的一部分播放服务;例如,CCL只需要播放服务(除基本服务外,基本服务将自动拉入),因此如果您遵循该模式,事情看起来会更小(运行到64K dex限制的可能性更小)和更少的冲突。Github中的CCL将其依赖项列为:
compile'com.google.android.gms:play services cast:6.5+”
因此,您可能希望开始使用版本,并遵循我刚才提出的建议(这同样适用于您拥有和使用play services的任何其他代码;只需输入您真正需要的代码即可)

将CCL依赖项更改为:“compile”com.google.android.gms:play services cast:6.5+”仍然存在错误。还将BaseGameUtils依赖项更改为:compile”com.google.android.gms:play services:6.5+“仍然存在错误。我在这里缺少什么?我希望android studio中的错误信息更丰富,例如,prov确定引用两个不同库(同名)的位置。对于游戏一,您需要完整的play服务还是只需要一个更小的包(可能是游戏的play服务)?尝试添加一个领导板。查看“类型a数字挑战”,我需要plus和games API。所以,结构如下:VideoBrowserActivity使用CastCompanionLibrary和BaseGameUtils。Cast Companion library使用gms:play services Cast:6.5+。BaseGameUtils使用plus和game services,但问题是如何在不出现渐变构建错误的情况下包含依赖项。我应该补充一点,我能够o将依赖关系从google-play-services_lib切换到gms:play services cast:6.5+,并仍然获得一个构建。您还可以尝试将游戏端的play services限制为play services game和play services plus(类似于您为ccl所做的),看看这是否有帮助。完成此操作后,请将更新的gradle文件复制到此处(至少是依赖项)这样我们就可以看到您拥有什么了。此时已接近工作状态。由于字符限制,无法将所有依赖项放在此处。下面是BaseGameUtils依赖项:依赖项{compile'com.android.support:appcompat-v7:20.0.+'compile'com.android.support:support-v4:20.0.+'compile'com.google.android.gms:play services games:6.5++'compile'com.google.android.gms:play services plus:6.5++}