简体   繁体   中英

Android libgdx and Google Game Services exited with a 2

Alright I have been working on this for almost a week and it is getting annoying now. My project compiles in desktop mode perfectly all the time, the Android version works fine until I start intergrating Google play services. I understand it is a duplicate somewhere, have tried deleting the build and having it remade, have tried various other solutions but to no avail. Here is my gradle build file. I have included the GameHelper as a class in my module.

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

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

    version = '1.0'
    ext {
        appName = "Collide_5"
        gdxVersion = '1.7.0'
        roboVMVersion = '1.8.0'
        box2DLightsVersion = '1.4'
        ashleyVersion = '1.6.0'
        aiVersion = '1.6.0'
    }

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

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"
    }
}

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-x86"
        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-x86"
        compile "com.google.android.gms:play-services:8.3.0"


    }
}

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


    dependencies {
        compile "com.badlogicgames.gdx:gdx:$gdxVersion"
        compile "com.badlogicgames.gdx:gdx-box2d:$gdxVersion"
        compile "net.dermetfan.libgdx-utils:libgdx-utils-box2d:0.13.1"
        compile "net.dermetfan.libgdx-utils:libgdx-utils:0.13.1"
        compile "com.underwaterapps.overlap2druntime:overlap2d-runtime-libgdx:0.1.0"
    }
}

tasks.eclipse.doLast {
    delete ".project"

Well to get rid of the error I started a new Libgdx project from scratch and added BasegameUtils(Base) as a library project and DID NOT add Google Game Services as a dependency, since it is a dependency in Base. I made Base a library dependency compile in the Android project. I am able to report so far so good, now all that I have to do is add to the project, are the individual Google services required. What I have done so far is add an interface to the core package and integrated that into my Android and Desktop project. I still have other issues I am working on, but the problem of the dex failure on Android builds is gone.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM