在 gradle 依赖项中,我包含以下内容
compile 'com.google.android.gms:play-services:7.5.0'
compile 'com.google.android.gms:play-services-ads:8.3.0'
但它给出了以下错误。
错误:任务“:app:processDebugResources”执行失败。
Error: more than one library with package name 'com.google.android.gms' You can temporarily disable this error with android.enforceUniquePackageName=false However, this is temporary and will be enforced in 1.0
如何解决
最佳答案
compile 'com.google.android.gms:play-services:7.5.0'
的第一行已包含广告 API ( source ):
Selectively compiling APIs into your executable
In versions of Google Play services prior to 6.5, you had to compile the entire package of APIs into your app. In some cases, doing so made it more difficult to keep the number of methods in your app (including framework APIs, library methods, and your own code) under the 65,536 limit.
From version 6.5, you can instead selectively compile Google Play service APIs into your app. For example, to include only the Google Fit and Android Wear APIs, replace the following line in your build.gradle file:
compile 'com.google.android.gms:play-services:8.3.0'
with these lines:
compile 'com.google.android.gms:play-services-fitness:8.3.0'
compile 'com.google.android.gms:play-services-wearable:8.3.0'
如上所述,仅包含您需要的 API 可能是一个更好的主意。上面的链接提供了可用 API 的表格。
关于android - 在Android中,当Google Play服务已使用时如何添加Admob,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33702645/