Slava Simonov
Slava Simonov

Reputation: 7

LibGDX Android Error while deploying application: java.lang.ExceptionInInitializerError

I'm getting this exception, while trying to run my 2D application on a phone (Huawei Honor 4C). Application builds and runs, but after black screen it is being killed with that exception. During searching I've found that it could be because I don't have libgdx.so library in libs folder. But I do have it. Here's a full logcat output:

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.

I have tried to delete application completely, to clean and rebuild project, but nothing seems to work.

When the instant run is disabled I am getting an error during Gradle building

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

When I install multidex support I have this slightly another error:

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

Project build.gradle file:

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 file:

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

Upvotes: 0

Views: 1487

Answers (2)

Slava Simonov
Slava Simonov

Reputation: 7

So, the problem is finally solved. And what I've done:

  • I've created a new libgdx project with last libraries and copied there my java code, manifest.xml and dependencies from gradle. Than I've run the project and caught the same mistake.

  • After that I've disabled in gradle dependency to my advertiser (adincube) and run. And... everything worked perfectly.

  • Finally I've enabled the dependency again and... it worked again. Since then it have never crashed, I've even enabled Instant run again.

So, I've decided, that the problem might had been in old libraries.

Thanks to everyone, who'd wasted his time and tried to help me.

Upvotes: 0

AAryan
AAryan

Reputation: 20140

Due to some reason libgdx.so was not copied to any of the armeabi, armeabi-v7a,arm64-v8a, x86, x86_64 folders in the android project's lib folder.

Check your lib folder inside your android app module.

If you're using gradle build system. Add these files into your android dependency.

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"

And one more thing check your android build.gradle file, there is task that copy .so file from respective jar to libs for different architecture.

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

EDIT

First of all vis-ui:0.9.4 and libgdx-utils:0.13.2 build on gdx version 1.7.1 so use gdxVersion = '1.7.1

Declare MultiDexApplication as application implementation in your AndroidManifest.xml.

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

Upvotes: 3

Related Questions