Oliver Dixon
Oliver Dixon

Reputation: 7424

Box2d will not load using LibsGDX with Gradle

My setup: Android Studio 0.8.1

Following the tutorial: https://github.com/libgdx/libgdx/wiki/Dependency-management-with-Gradle

I've spend days trying to get this to work out of much frustration.

Trying to run this on a Nexus 4.

My gradle build file:

apply plugin: 'android'

android {
compileSdkVersion 19
buildToolsVersion "19.1.0"

defaultConfig {
    minSdkVersion 14
    targetSdkVersion 19
}

buildTypes {
    release {
        runProguard false
        proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
    }
}
}

configurations { natives }

dependencies {
configurations { natives }

compile "com.badlogicgames.gdx:gdx:1.2.0"
compile "com.badlogicgames.gdx:gdx-backend-android:1.2.0"
natives "com.badlogicgames.gdx:gdx-platform:1.2.0:natives-armeabi"
natives "com.badlogicgames.gdx:gdx-platform:1.2.0:natives-armeabi-v7a"

compile "com.badlogicgames.gdx:gdx-box2d:1.2.0"
}

Now when I try to run the app I always get the error message:

07-04 23:03:20.030  10440-10440/com.myappcompany.MyApp E/AndroidRuntime﹕ FATAL EXCEPTION: main
Process: com.myappcompany.MyApp, PID: 10440
java.lang.ExceptionInInitializerError
at com.myappcompany.MyApp.objects.Area.createWorld(Area.java:101)
at com.myappcompany.MyApp.ActivitySplash$1.run(ActivitySplash.java:60)
at android.os.Handler.handleCallback(Handler.java:733)
at android.os.Handler.dispatchMessage(Handler.java:95)
at android.os.Looper.loop(Looper.java:136)
at android.app.ActivityThread.main(ActivityThread.java:5001)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:515)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:785)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:601)
at dalvik.system.NativeStart.main(Native Method)
Caused by: com.badlogic.gdx.utils.GdxRuntimeException: Couldn't load shared library 'gdx-box2d' for target: Linux, 32-bit
at com.badlogic.gdx.utils.SharedLibraryLoader.load(SharedLibraryLoader.java:116)
at com.badlogic.gdx.physics.box2d.World.<clinit>(World.java:187)
at com.myappcompany.MyApp.objects.Area.createWorld(Area.java:101)
at com.myappcompany.MyApp.ActivitySplash$1.run(ActivitySplash.java:60)
at android.os.Handler.handleCallback(Handler.java:733)
at android.os.Handler.dispatchMessage(Handler.java:95)
at android.os.Looper.loop(Looper.java:136)
at android.app.ActivityThread.main(ActivityThread.java:5001)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:515)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:785)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:601)
at dalvik.system.NativeStart.main(Native Method)
Caused by: java.lang.UnsatisfiedLinkError: Couldn't load gdx-box2d from loader dalvik.system.PathClassLoader[DexPathList[[zip file "/data/app/com.myappcompany.MyApp-1.apk"],nativeLibraryDirectories=[/data/app-lib/com.myappcompany.MyApp-1, /vendor/lib, /system/lib]]]: findLibrary returned null
at java.lang.Runtime.loadLibrary(Runtime.java:358)
at java.lang.System.loadLibrary(System.java:526)
at com.badlogic.gdx.utils.SharedLibraryLoader.load(SharedLibraryLoader.java:112)
at com.badlogic.gdx.physics.box2d.World.<clinit>(World.java:187)
at com.myappcompany.MyApp.objects.Area.createWorld(Area.java:101)
at com.myappcompany.MyApp.ActivitySplash$1.run(ActivitySplash.java:60)
at android.os.Handler.handleCallback(Handler.java:733)
at android.os.Handler.dispatchMessage(Handler.java:95)
at android.os.Looper.loop(Looper.java:136)
at android.app.ActivityThread.main(ActivityThread.java:5001)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:515)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:785)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:601)
at dalvik.system.NativeStart.main(Native Method)

Upvotes: 0

Views: 271

Answers (1)

Steve
Steve

Reputation: 1065

I have this exact same issue. It appears to be something with the libraries not getting copied over or not found in the correct lib path on the device.

Fwiw I'm running this from an emulator (if that matters), but I'm really stuck/frustrated

Upvotes: 1

Related Questions