【问题标题】:Error using AdMob and Google Play Game Services at the same time同时使用 AdMob 和 Google Play 游戏服务时出错
【发布时间】:2017-08-30 19:04:55
【问题描述】:

我正在使用 libgdx 和 Android 工作室。我已经成功实现了 google play 游戏服务(排行榜等)。现在我想实现 admob,但我得到了错误。

这是我的 build.gradle 的一部分:

project(":android") {
apply plugin: "android"

configurations { natives }

dependencies {
    compile project(":core")
    compile "com.badlogicgames.gdx:gdx-backend-android:$gdxVersion"
    natives "com.badlogicgames.gdx:gdx-platform:$gdxVersion:natives-armeabi"
    natives "com.badlogicgames.gdx:gdx-platform:$gdxVersion:natives-armeabi-v7a"
    natives "com.badlogicgames.gdx:gdx-platform:$gdxVersion:natives-arm64-v8a"
    natives "com.badlogicgames.gdx:gdx-platform:$gdxVersion:natives-x86"
    natives "com.badlogicgames.gdx:gdx-platform:$gdxVersion:natives-x86_64"
    compile "com.badlogicgames.gdx:gdx-freetype:$gdxVersion"
    natives "com.badlogicgames.gdx:gdx-freetype-platform:$gdxVersion:natives-armeabi"
    natives "com.badlogicgames.gdx:gdx-freetype-platform:$gdxVersion:natives-armeabi-v7a"
    natives "com.badlogicgames.gdx:gdx-freetype-platform:$gdxVersion:natives-arm64-v8a"
    natives "com.badlogicgames.gdx:gdx-freetype-platform:$gdxVersion:natives-x86"
    natives "com.badlogicgames.gdx:gdx-freetype-platform:$gdxVersion:natives-x86_64"
    compile 'com.google.android.gms:play-services-games:11.2.0'
    compile 'com.google.android.gms:play-services-ads:11.2.0'
    //compile 'com.google.android.gms:play-services:10.0.1'
    compile fileTree(dir: '../libs', include: '*.jar')
    compile project(":BaseGameUtils")
}

}

如果我按 build->clean projects,一切似乎都很好,但是当我想在我的 android 手机上运行该应用程序时,我收到此错误:

Error:Execution failed for task 
':android:transformClassesWithJarMergingForRelease'.
> com.android.build.api.transform.TransformException: 
java.util.zip.ZipException: duplicate entry: 
com/google/android/gms/internal/zzqv.class

compile 'com.google.android.gms:play-services-ads:11.2.0' 部分搞砸了。如果我删除该行,一切都会像以前一样工作,但我不能使用 AdMob。

有人知道问题可能是什么吗?

我在使用 Eclipse 时,将 google-play-service 库作为项目包含在内,并且不需要在 build.gradle 中添加任何内容……为什么在 AndroidStudios 中会有所不同?

【问题讨论】:

  • libs 里面是什么?
  • tween-engine-api.jartween-engine-api-sources.jar。在我的 android/libs 中只有 libgdx 相关的东西。

标签: android libgdx admob google-play-services


【解决方案1】:

这是由于工件不匹配/版本冲突。

删除

compile 'com.google.android.gms:play-services-games:11.2.0'

从根build.gradle 文件的android 依赖项标签中,BaseGameUtils 已经具有该依赖项。检查BaseGameUtils 模块的build.gradle 中的支持版本。

此外,最好使用来自libs 文件夹的 repo 中的工件。

你也可以注入补间引擎

repositories {
    maven { url "https://jitpack.io" }
}

compile 'com.github.arcnor:universal-tween-engine:6.3.4'
compile 'com.github.arcnor:universal-tween-engine:6.3.4:sources'

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2017-10-18
    • 2014-10-31
    • 2014-01-19
    • 1970-01-01
    • 1970-01-01
    • 2016-06-24
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多