2017-08-30 72 views
0

我正在使用libgdx和Android工作室。我已经成功实施谷歌玩游戏服务(排行榜等)。现在我想实现admob,但是我得到错误。同时使用AdMob和Google Play游戏服务时出错

这是我的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") 
} 

}

如果我按建设 - >清洁项目,似乎一切都很好,但是当我想要我的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中有所不同?

+0

里面是什么'libs'? – Aryan

+0

'tween-engine-api.jar'和'tween-engine-api-sources.jar'。而在我的android/libs只有libgdx相关的东西。 – lijas

回答

0

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

删除

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

从根build.gradle文件的Android依赖标签,BaseGameUtils已经拥有了这种依赖性。检查BaseGameUtils模块的build.gradle的支持版本。

另外它最好使用来自libs文件夹的回购产品。

您也可以注入吐温引擎

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'