2017-08-30 94 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' 
相關問題