android - 在Android中,当Google Play服务已使用时如何添加Admob

标签 android admob

在 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/

相关文章:

java - 从方法中中断线程

java - jReddit 和 Java.lang.NoClassDefFoundError 错误

android - 如何观察 Android WorkManager Worker

javascript - 将数组从js传递到android

firebase - 用于 flutter 的 firebase_admob 0.6.1 的 App ID 问题

java - 在应用程序 Android 中应用自定义字体后,xml 中 textview 的粗体 textStyle 属性不起作用

java - 在所有 Activity 中显示恒定的 admob 广告横幅

android - Admob 在多个 Activity 中添加

android - Admob Interstitial 关闭现有 Activity

angular - IONIC 3 - Admob Free 在测试错误时不显示广告