部署应用程序时出现LibGDX And​​roid错误:java.lang.ExceptionInInitializerError

时间:2017-04-08 14:18:01

标签: java android libgdx

我试图在手机上运行我的2D应用程序(华为Honor 4C)时遇到此异常。  应用程序构建并运行,但在黑屏后,它被异常杀死。 在搜索过程中,我发现它可能是因为我在libs文件夹中没有libgdx.so库。但我确实拥有它。 这是一个完整的logcat输出:

Connected to process 24969 on device huawei-chm_u01-A8K4C15811024023
W/art: Failed to find OatDexFile for DexFile /data/data/com.chemistry.chemistasks/files/instant-run/dex/slice-slice_6-classes.dex ( canonical path /data/data/com.chemistry.chemistasks/files/instant-run/dex/slice-slice_6-classes.dex) with checksum 0xba4b6453 in OatFile /data/data/com.chemistry.chemistasks/cache/slice-slice_6-classes.dex
E/AndroidRuntime: FATAL EXCEPTION: main
                  Process: com.chemistry.chemistasks, PID: 24969
                  java.lang.ExceptionInInitializerError
                      at java.lang.reflect.Constructor.newInstance(Native Method)
                      at java.lang.Class.newInstance(Class.java:1606)
                      at android.app.Instrumentation.newActivity(Instrumentation.java:1069)
                      at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2345)
                      at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2510)
                      at android.app.ActivityThread.access$1200(ActivityThread.java:163)
                      at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1371)
                      at android.os.Handler.dispatchMessage(Handler.java:102)
                      at android.os.Looper.loop(Looper.java:135)
                      at android.app.ActivityThread.main(ActivityThread.java:5595)
                      at java.lang.reflect.Method.invoke(Native Method)
                      at java.lang.reflect.Method.invoke(Method.java:372)
                      at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:960)
                      at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:755)
                   Caused by: com.badlogic.gdx.utils.GdxRuntimeException: Couldn't load shared library 'gdx' for target: Linux, 32-bit
                      at com.badlogic.gdx.utils.SharedLibraryLoader.load(SharedLibraryLoader.java:118)
                      at com.badlogic.gdx.utils.GdxNativesLoader.load(GdxNativesLoader.java:34)
                      at com.badlogic.gdx.backends.android.AndroidApplication.<clinit>(AndroidApplication.java:61)
                      at java.lang.reflect.Constructor.newInstance(Native Method) 
                      at java.lang.Class.newInstance(Class.java:1606) 
                      at android.app.Instrumentation.newActivity(Instrumentation.java:1069) 
                      at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2345) 
                      at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2510) 
                      at android.app.ActivityThread.access$1200(ActivityThread.java:163) 
                      at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1371) 
                      at android.os.Handler.dispatchMessage(Handler.java:102) 
                      at android.os.Looper.loop(Looper.java:135) 
                      at android.app.ActivityThread.main(ActivityThread.java:5595) 
                      at java.lang.reflect.Method.invoke(Native Method) 
                      at java.lang.reflect.Method.invoke(Method.java:372) 
                      at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:960) 
                      at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:755) 
                   Caused by: java.lang.UnsatisfiedLinkError: com.android.tools.fd.runtime.IncrementalClassLoader$DelegateClassLoader[DexPathList[[dex file "/data/data/com.chemistry.chemistasks/files/instant-run/dex/slice-vungle-publisher-adaptive-id-4.0.3_5a23c1a26eadc757a06ed8b39936ff9e0f1bffb8-classes.dex", dex file "/data/data/com.chemistry.chemistasks/files/instant-run/dex/slice-vis-ui-0.9.4_b536d0f585708e56151e61951243d44b0a249b87-classes.dex", dex file "/data/data/com.chemistry.chemistasks/files/instant-run/dex/slice-support-annotations-25.0.1_7cc704876d049d983d95765479447af073b91121-classes.dex", dex file "/data/data/com.chemistry.chemistasks/files/instant-run/dex/slice-startapp-3.5.6_01afe35d035159f0d4a019317380cb0f2e8d3f96-classes.dex", dex file "/data/data/com.chemistry.chemistasks/files/instant-run/dex/slice-slice_9-classes.dex", dex file "/data/data/com.chemistry.chemistasks/files/instant-run/dex/slice-slice_8-classes.dex", dex file "/data/data/com.chemistry.chemistasks/files/instant-run/dex/slice-slice_7-classes.dex", dex file "/data/data/com.chemistry.chemistasks/files/instant-run/dex/slice-slice_6-classes.dex", dex file "/data/data/com.chemistry.chemistasks/files/instant-run/dex/slice-slice_5-classes.dex", dex file "/data/data/com.chemistry.chemistasks/files/instant-run/dex/slice-slice_4-classes.dex", dex file "/data/data/com.chemistry.chemistasks/files/instant-run/dex/slice-slice_3-classes.dex", dex file "/data/data/com.chemistry.chemistasks/files/instant-run/dex/slice-slice_2-classes.dex", dex file "/data/data/com.chemistry.chemistasks/files/instant-run/dex/slice-slice_1-classes.dex", dex file "/data/data/com.chemistry.chemistasks/files/instant-run/dex/slice-slice_0-classes.dex", dex file "/data/data/com.chemistry.chemistasks/files/instant-run/dex/slice-mytarget-sdk-4.5.10_e5e23ba1c57b02aac027515a1437e8fdb95e7977-classes.dex", dex file "/data/data/com.chemistry.chemistasks/files/instant-run/dex/slice-libgdx-utils-0.13.2_ed5faf982a8ccc1840334d9a535327e0b67ee41f-classes.dex", dex file "/data/data/com.chemistry.chemistasks/files/instant-run/dex/slice-javax.inject-1_4de1f8a7774f2a75ccc54179ef69b545dfc7b7a5-classes.dex", dex file "/data/data/com.chemistry.chemistasks/files/instant-run/dex/slice-inmobi-ads-5.3.1_4dff993e7f19ac8f4d2bde85d53bd169c777ce80-classes.dex", dex file "/data/data/com.chemistry.chemistasks/files/instant-run/dex/slice-gdx-freetype-1.8.0_26d2af7ef484053d6e74d24ece54464af8bfb0ff-classes.dex", dex file "/data/data/com.chemistry.chemistasks/files/instant-run/dex/slice-gdx-backend-android-1.8.0_50c6ca6cf6e5a1d62adf4aa6a1779276f750f633-classes.dex", dex file "/data/data/com.chemistry.chemistasks/files/instant-run/dex/sli
I/Process: Sending signal. PID: 24969 SIG: 9
Application terminated.

我试图完全删除应用程序,以清理和重建项目,但似乎没有任何工作。

即时运行被禁用时,我在Gradle构建期间出现错误

Executing tasks: [:android:assembleDebug]

Configuration on demand is an incubating feature.
Incremental java compilation is an incubating feature.
:android:preBuild UP-TO-DATE
:android:preDebugBuild UP-TO-DATE
:android:checkDebugManifest
:android:preReleaseBuild UP-TO-DATE
:core:compileJava UP-TO-DATE
:core:processResources UP-TO-DATE
:core:classes UP-TO-DATE
:core:jar UP-TO-DATE
:android:prepareComAdincubePartnerAdbuddiz3111Library UP-TO-DATE
:android:prepareComAdincubePartnerAdcolony310Library UP-TO-DATE
:android:prepareComAdincubePartnerAdmob1001Library UP-TO-DATE
:android:prepareComAdincubePartnerApplovin642Library UP-TO-DATE
:android:prepareComAdincubePartnerAppnext177Library UP-TO-DATE
:android:prepareComAdincubePartnerAppnextCore177Library UP-TO-DATE
:android:prepareComAdincubePartnerAppnextNative177Library UP-TO-DATE
:android:prepareComAdincubePartnerAppnextSdk177Library UP-TO-DATE
:android:prepareComAdincubePartnerChartboost661Library UP-TO-DATE
:android:prepareComAdincubePartnerFacebook4200Library UP-TO-DATE
:android:prepareComAdincubePartnerInmobi531Library UP-TO-DATE
:android:prepareComAdincubePartnerMailru4510Library UP-TO-DATE
:android:prepareComAdincubePartnerStartapp356Library UP-TO-DATE
:android:prepareComAdincubePartnerUnity208Library UP-TO-DATE
:android:prepareComAdincubePartnerVungle403Library UP-TO-DATE
:android:prepareComAdincubeSdkAdinCubeCore1130Library UP-TO-DATE
:android:prepareComAdincubeSdkAdinCubeJava1fff1130Library UP-TO-DATE
:android:prepareComGoogleAndroidExoplayerExoplayerR203Library UP-TO-DATE
:android:prepareComGoogleAndroidGmsPlayServicesAds1001Library UP-TO-DATE
:android:prepareComGoogleAndroidGmsPlayServicesAdsLite1001Library UP-TO-DATE
:android:prepareComGoogleAndroidGmsPlayServicesBase1001Library UP-TO-DATE
:android:prepareComGoogleAndroidGmsPlayServicesBasement1001Library UP-TO-DATE
:android:prepareComGoogleAndroidGmsPlayServicesClearcut1001Library UP-TO-DATE
:android:prepareComGoogleAndroidGmsPlayServicesGass1001Library UP-TO-DATE
:android:prepareComGoogleAndroidGmsPlayServicesIid1001Library UP-TO-DATE
:android:prepareComGoogleAndroidGmsPlayServicesTasks1001Library UP-TO-DATE
:android:prepareDebugDependencies
:android:compileDebugAidl UP-TO-DATE
:android:compileDebugRenderscript UP-TO-DATE
:android:generateDebugBuildConfig UP-TO-DATE
:android:generateDebugResValues UP-TO-DATE
:android:generateDebugResources UP-TO-DATE
:android:mergeDebugResources UP-TO-DATE
:android:processDebugManifest
:android:processDebugResources
:android:generateDebugSources
:android:incrementalDebugJavaCompilationSafeguard UP-TO-DATE
:android:compileDebugJavaWithJavac UP-TO-DATE
:android:compileDebugNdk UP-TO-DATE
:android:compileDebugSources UP-TO-DATE
:android:mergeDebugShaders UP-TO-DATE
:android:compileDebugShaders UP-TO-DATE
:android:generateDebugAssets UP-TO-DATE
:android:mergeDebugAssets UP-TO-DATE
:android:transformClassesWithDexForDebug FAILED

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':android:transformClassesWithDexForDebug'.
> com.android.build.api.transform.TransformException: com.android.ide.common.process.ProcessException: java.util.concurrent.ExecutionException: com.android.dex.DexIndexOverflowException: method ID not in [0, 0xffff]: 65536

* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.

BUILD FAILED

Total time: 8.255 secs

当我安装multidex支持时,我有稍微有点错误

04-09 15:32:58.430 20112-20112/? I/art: Late-enabling -Xcheck:jni
04-09 15:32:58.510 20112-20112/com.chemistry.chemistasks E/AndroidRuntime: FATAL EXCEPTION: main
                                                                               Process: com.chemistry.chemistasks, PID: 20112
                                                                               java.lang.ExceptionInInitializerError
                                                                                   at java.lang.reflect.Constructor.newInstance(Native Method)
                                                                                   at java.lang.Class.newInstance(Class.java:1606)
                                                                                   at android.app.Instrumentation.newActivity(Instrumentation.java:1069)
                                                                                   at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2345)
                                                                                   at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2510)
                                                                                   at android.app.ActivityThread.access$1200(ActivityThread.java:163)
                                                                                   at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1371)
                                                                                   at android.os.Handler.dispatchMessage(Handler.java:102)
                                                                                   at android.os.Looper.loop(Looper.java:135)
                                                                                   at android.app.ActivityThread.main(ActivityThread.java:5595)
                                                                                   at java.lang.reflect.Method.invoke(Native Method)
                                                                                   at java.lang.reflect.Method.invoke(Method.java:372)
                                                                                   at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:960)
                                                                                   at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:755)
                                                                                Caused by: com.badlogic.gdx.utils.GdxRuntimeException: Couldn't load shared library 'gdx' for target: Linux, 32-bit
                                                                                   at com.badlogic.gdx.utils.SharedLibraryLoader.load(SharedLibraryLoader.java:124)
                                                                                   at com.badlogic.gdx.utils.GdxNativesLoader.load(GdxNativesLoader.java:33)
                                                                                   at com.badlogic.gdx.backends.android.AndroidApplication.<clinit>(AndroidApplication.java:63)
                                                                                   at java.lang.reflect.Constructor.newInstance(Native Method) 
                                                                                   at java.lang.Class.newInstance(Class.java:1606) 
                                                                                   at android.app.Instrumentation.newActivity(Instrumentation.java:1069) 
                                                                                   at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2345) 
                                                                                   at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2510) 
                                                                                   at android.app.ActivityThread.access$1200(ActivityThread.java:163) 
                                                                                   at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1371) 
                                                                                   at android.os.Handler.dispatchMessage(Handler.java:102) 
                                                                                   at android.os.Looper.loop(Looper.java:135) 
                                                                                   at android.app.ActivityThread.main(ActivityThread.java:5595) 
                                                                                   at java.lang.reflect.Method.invoke(Native Method) 
                                                                                   at java.lang.reflect.Method.invoke(Method.java:372) 
                                                                                   at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:960) 
                                                                                   at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:755) 
                                                                                Caused by: java.lang.UnsatisfiedLinkError: dalvik.system.PathClassLoader[DexPathList[[zip file "/data/app/com.chemistry.chemistasks-2/base.apk"],nativeLibraryDirectories=[/data/app/com.chemistry.chemistasks-2/lib/arm64, /vendor/lib64, /system/lib64]]] couldn't find "libgdx.so"
                                                                                   at java.lang.Runtime.loadLibrary(Runtime.java:378)
                                                                                   at java.lang.System.loadLibrary(System.java:997)
                                                                                   at com.badlogic.gdx.utils.SharedLibraryLoader.load(SharedLibraryLoader.java:118)
                                                                                   at com.badlogic.gdx.utils.GdxNativesLoader.load(GdxNativesLoader.java:33) 
                                                                                   at com.badlogic.gdx.backends.android.AndroidApplication.<clinit>(AndroidApplication.java:63) 
                                                                                   at java.lang.reflect.Constructor.newInstance(Native Method) 
                                                                                   at java.lang.Class.newInstance(Class.java:1606) 
                                                                                   at android.app.Instrumentation.newActivity(Instrumentation.java:1069) 
                                                                                   at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2345) 
                                                                                   at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2510) 
                                                                                   at android.app.ActivityThread.access$1200(ActivityThread.java:163) 
                                                                                   at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1371) 
                                                                                   at android.os.Handler.dispatchMessage(Handler.java:102) 
                                                                                   at android.os.Looper.loop(Looper.java:135) 
                                                                                   at android.app.ActivityThread.main(ActivityThread.java:5595) 
                                                                                   at java.lang.reflect.Method.invoke(Native Method) 
                                                                                   at java.lang.reflect.Method.invoke(Method.java:372) 
                                                                                   at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:960) 
                                                                                   at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:755) 
    04-09 15:32:58.840 20112-20112/com.chemistry.chemistasks I/Process: Sending signal. PID: 20112 SIG: 9

项目build.gradle 文件:

buildscript {
    repositories {
        mavenCentral()
        maven { url "https://oss.sonatype.org/content/repositories/snapshots/" }
        jcenter()
    }
    dependencies {
        classpath 'de.richsource.gradle.plugins:gwt-gradle-plugin:0.6'
        classpath 'com.android.tools.build:gradle:2.2.2'
        classpath 'org.robovm:robovm-gradle-plugin:1.12.0'
    }
}

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

    version = '1.0'
    ext {
        appName = "ChemisTasks"
        gdxVersion = '1.9.6'
        roboVMVersion = '1.12.0'
        box2DLightsVersion = '1.4'
        ashleyVersion = '1.7.0'
        aiVersion = '1.7.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-freetype-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-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-x86"
    }
}

project(":ios") {
    apply plugin: "java"
    apply plugin: "robovm"


    dependencies {
        compile project(":core")
        compile "org.robovm:robovm-rt:$roboVMVersion"
        compile "org.robovm:robovm-cocoatouch:$roboVMVersion"
        compile "com.badlogicgames.gdx:gdx-backend-robovm:$gdxVersion"
        compile "com.badlogicgames.gdx:gdx-platform:$gdxVersion:natives-ios"
        compile "com.badlogicgames.gdx:gdx-freetype-platform:$gdxVersion:natives-ios"
    }
}

project(":html") {
    apply plugin: "gwt"
    apply plugin: "war"


    dependencies {
        compile project(":core")
        compile "com.badlogicgames.gdx:gdx-backend-gwt:$gdxVersion"
        compile "com.badlogicgames.gdx:gdx:$gdxVersion:sources"
        compile "com.badlogicgames.gdx:gdx-backend-gwt:$gdxVersion:sources"
        compile "com.kotcrab.vis:vis-ui:0.9.4:sources"
        compile "net.dermetfan.libgdx-utils:libgdx-utils:0.13.2:sources"
    }
}

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


    dependencies {
        compile "com.badlogicgames.gdx:gdx:$gdxVersion"
        compile "com.badlogicgames.gdx:gdx-freetype:$gdxVersion"
        compile "com.kotcrab.vis:vis-ui:0.9.4"
        compile "net.dermetfan.libgdx-utils:libgdx-utils:0.13.2"
    }
}

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

Android build.gradle 文件:

android {
    buildToolsVersion "23.0.3"
    compileSdkVersion 23
    sourceSets {
        main {
            manifest.srcFile 'AndroidManifest.xml'
            java.srcDirs = ['src']
            aidl.srcDirs = ['src']
            renderscript.srcDirs = ['src']
            res.srcDirs = ['res']
            assets.srcDirs = ['assets']
            jniLibs.srcDirs = ['libs']
        }

        instrumentTest.setRoot('tests')
    }
    defaultConfig {
        applicationId "com.chemistry.chemistasks"
        minSdkVersion 11
        targetSdkVersion 25
        multiDexEnabled true
    }
}


// called every time gradle gets executed, takes the native dependencies of
// the natives configuration, and extracts them to the proper libs/ folders
// so they get packed with the APK.
task copyAndroidNatives() {
    file("libs/armeabi/").mkdirs();
    file("libs/armeabi-v7a/").mkdirs();
    file("libs/x86/").mkdirs();

    configurations.natives.files.each { jar ->
        def outputDir = null
        if(jar.name.endsWith("natives-armeabi-v7a.jar")) outputDir = file("libs/armeabi-v7a")
        if(jar.name.endsWith("natives-armeabi.jar")) outputDir = file("libs/armeabi")
        if(jar.name.endsWith("natives-x86.jar")) outputDir = file("libs/x86")
        if(outputDir != null) {
            copy {
                from zipTree(jar)
                into outputDir
                include "*.so"
            }
        }
    }
}

task run(type: Exec) {
    def path
    def localProperties = project.file("../local.properties")
    if (localProperties.exists()) {
        Properties properties = new Properties()
        localProperties.withInputStream { instr ->
            properties.load(instr)
        }
        def sdkDir = properties.getProperty('sdk.dir')
        if (sdkDir) {
            path = sdkDir
        } else {
            path = "$System.env.ANDROID_HOME"
        }
    } else {
        path = "$System.env.ANDROID_HOME"
    }

    def adb = path + "/platform-tools/adb"
    commandLine "$adb", 'shell', 'am', 'start', '-n', 'com.chemistry.chemistasks/com.chemistry.chemistasks.AndroidLauncher'
}

// sets up the Android Eclipse project, using the old Ant based build.
eclipse {
    // need to specify Java source sets explicitely, SpringSource Gradle Eclipse plugin
    // ignores any nodes added in classpath.file.withXml
    sourceSets {
        main {
            java.srcDirs "src", 'gen'
        }
    }

    jdt {
        sourceCompatibility = 1.6
        targetCompatibility = 1.6
    }

    classpath {
        plusConfigurations += [ project.configurations.compile ]        
        containers 'com.android.ide.eclipse.adt.ANDROID_FRAMEWORK', 'com.android.ide.eclipse.adt.LIBRARIES'       
    }

    project {
        name = appName + "-android"
        natures 'com.android.ide.eclipse.adt.AndroidNature'
        buildCommands.clear();
        buildCommand "com.android.ide.eclipse.adt.ResourceManagerBuilder"
        buildCommand "com.android.ide.eclipse.adt.PreCompilerBuilder"
        buildCommand "org.eclipse.jdt.core.javabuilder"
        buildCommand "com.android.ide.eclipse.adt.ApkBuilder"
    }
}

// sets up the Android Idea project, using the old Ant based build.
idea {
    module {
        sourceDirs += file("src");
        scopes = [ COMPILE: [plus:[project.configurations.compile]]]        

        iml {
            withXml {
                def node = it.asNode()
                def builder = NodeBuilder.newInstance();
                builder.current = node;
                builder.component(name: "FacetManager") {
                    facet(type: "android", name: "Android") {
                        configuration {
                            option(name: "UPDATE_PROPERTY_FILES", value:"true")
                        }
                    }
                }
            }
        }
    }
}
dependencies {
    compile ('com.adincube.sdk:AdinCube-Java-1fff:1.+@aar') {
        exclude module: 'support-v4'
        transitive = true
    }
    compile 'com.android.support:multidex:1.0.1'
}
repositories {
    jcenter()
    maven {
        url 'http://repository.adincube.com/maven'
    }
}

2 个答案:

答案 0 :(得分:1)

由于某种原因libgdx.so未被复制到android中的任何armeabiarmeabi-v7aarm64-v8ax86x86_64个文件夹project的lib文件夹。

检查android app模块中的lib文件夹。

如果您正在使用gradle构建系统。将这些文件添加到您的Android依赖项中。

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"

另外还有一件事是检查你的android build.gradle文件,有任务将.so文件从相应的jar文件复制到不同架构的库。

task copyAndroidNatives() { 
    file("libs/armeabi/").mkdirs();
    file("libs/armeabi-v7a/").mkdirs();
    file("libs/arm64-v8a/").mkdirs();
    file("libs/x86_64/").mkdirs();
    file("libs/x86/").mkdirs();

    configurations.natives.files.each { jar ->
        def outputDir = null
        if(jar.name.endsWith("natives-arm64-v8a.jar")) outputDir = file("libs/arm64-v8a")
        if(jar.name.endsWith("natives-armeabi-v7a.jar")) outputDir = file("libs/armeabi-v7a")        
        if(jar.name.endsWith("natives-armeabi.jar")) outputDir = file("libs/armeabi")
        if(jar.name.endsWith("natives-x86_64.jar")) outputDir = file("libs/x86_64")
        if(jar.name.endsWith("natives-x86.jar")) outputDir = file("libs/x86")
        if(outputDir != null) {
            copy {
                from zipTree(jar)
                into outputDir
                include "*.so"
            }
        }
    }
}

修改

首先,vis-ui:0.9.4libgdx-utils:0.13.2构建于gdx版本1.7.1上,因此请使用gdxVersion = '1.7.1

在AndroidManifest.xml中声明MultiDexApplication作为应用程序实现。

<application
    android:name="android.support.multidex.MultiDexApplication"
    .. >
 ..
</application>'` otherwise update all to required version.

答案 1 :(得分:0)

所以,问题终于解决了。而我所做的:

  • 我用最后的库创建了一个新的libgdx项目,并从gradle中复制了我的java代码,manifest.xml和依赖项。比我运行项目并犯了同样的错误。

  • 之后,我已禁用与广告客户的gradle依赖关系 (adincube)并运行。而且......一切都很完美。

  • 最后我再次启用了依赖关系......它再次起作用。从那以后它从未崩溃,我甚至再次启用了Instant run。

所以,我已经决定,问题可能发生在旧图书馆。

感谢所有人,他浪费了他的时间并试图帮助我。