android studio错误:transformClassesWithJarMergingForDebug

时间:2016-10-13 17:52:00

标签: java android android-gradle google-play-services

我正在测试游戏。但是当我尝试在我的设备上运行应用程序时,它给了我这个错误:

enter image description here

我已经尝试清理项目,但错误仍然存​​在。

项目:

buildscript {
    repositories {
        mavenLocal()
        mavenCentral()
        maven { url "https://oss.sonatype.org/content/repositories/snapshots/" }
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:2.1.3'
    }
}

allprojects {
    apply plugin: "eclipse"
    apply plugin: "idea"

    version = '1.0'
    ext {
        appName = "RocketHedgehog"
        gdxVersion = '1.9.3'
        roboVMVersion = '2.1.0'
        box2DLightsVersion = '1.4'
        ashleyVersion = '1.7.0'
        aiVersion = '1.8.0'
    }

    repositories {
        mavenLocal()
        mavenCentral()
        maven { url "https://oss.sonatype.org/content/repositories/snapshots/" }
        maven { url "https://oss.sonatype.org/content/repositories/releases/" }
    }
}

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

    configurations {
        natives
        all*.exclude group: 'com.android.support', module: 'support-v4'
    }

    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-box2d:$gdxVersion"
        natives "com.badlogicgames.gdx:gdx-box2d-platform:$gdxVersion:natives-armeabi"
        natives "com.badlogicgames.gdx:gdx-box2d-platform:$gdxVersion:natives-armeabi-v7a"
        natives "com.badlogicgames.gdx:gdx-box2d-platform:$gdxVersion:natives-arm64-v8a"
        natives "com.badlogicgames.gdx:gdx-box2d-platform:$gdxVersion:natives-x86"
        natives "com.badlogicgames.gdx:gdx-box2d-platform:$gdxVersion:natives-x86_64"
        compile "com.google.android.gms:play-services-ads:9.4.0"
        compile "com.google.android.gms:play-services-games:9.6.1"
        compile project(':BaseGameUtils')
        compile 'com.android.support:multidex:1.0.1'
    }
}

project(":core") {
    apply plugin: "java"


    dependencies {
        compile "com.badlogicgames.gdx:gdx:$gdxVersion"
        compile "com.badlogicgames.gdx:gdx-box2d:$gdxVersion"
    }
}

project(":desktop") {
    apply plugin: "java"


    dependencies {
        compile project(":core")
        compile "com.badlogicgames.gdx:gdx-backend-lwjgl:$gdxVersion"
        compile "com.badlogicgames.gdx:gdx-platform:$gdxVersion:natives-desktop"
        compile "com.badlogicgames.gdx:gdx-box2d-platform:$gdxVersion:natives-desktop"
    }
}

tasks.eclipse.doLast {
    delete ".project"
}

BaseGameUtils :(图书馆)我需要这个来实现GPS

apply plugin: 'com.android.library'

buildscript {
    repositories {
        jcenter()
    }

    dependencies {
        classpath 'com.android.tools.build:gradle:1.3.1'
    }
}

dependencies {
    // Set defaults so that BaseGameUtils can be used outside of BasicSamples
    if (!project.hasProperty('appcompat_library_version')) {
        ext.appcompat_library_version = '20.0.+'
    }
    if (!project.hasProperty('support_library_version')) {
        ext.support_library_version = '20.0.+'
    }
    if (!project.hasProperty('gms_library_version')) {
        ext.gms_library_version = '8.4.0'
    }

    compile "com.android.support:appcompat-v7:${appcompat_library_version}"
    compile "com.android.support:support-v4:${support_library_version}"
    compile "com.google.android.gms:play-services-games:${gms_library_version}"
    compile "com.google.android.gms:play-services-plus:${gms_library_version}"
}

android {
    // Set defaults so that BaseGameUtils can be used outside of BasicSamples
    if (!project.hasProperty('android_compile_version')) {
        ext.android_compile_version = 23
    }
    if (!project.hasProperty('android_min_version')) {
        ext.android_min_version = 9
    }
    if (!project.hasProperty('android_version')) {
        ext.build_tools_version = "23.0.2"
    }

    compileSdkVersion android_compile_version
    buildToolsVersion build_tools_version

    defaultConfig {
        minSdkVersion android_min_version
        targetSdkVersion android_compile_version
    }
}

1 个答案:

答案 0 :(得分:0)

我建议您为google服务设置一个变量,并使它们具有相同的版本。

例如,您的<canvas id="canvas" width="300" height="300"></canvas> <button onClick="lines()">Draw over image</button> <button onClick="loadState()">Restore</button>一致地使用BaseGameUtils,但您的项目正在使用各种其他版本(8.4.09.6.1

9.4.0

然后,更新这些行以使用该变量。

ext {
    appName = "RocketHedgehog"
    gms_library_version = "8.4.0" // For consistency with library