Box2d不会使用带Gradle的LibsGDX加载

时间:2014-07-04 13:11:44

标签: java android gradle android-studio libgdx

我的设置: Android Studio 0.8.1

遵循教程: https://github.com/libgdx/libgdx/wiki/Dependency-management-with-Gradle

我花了好几天时间试图让这件事变得非常沮丧。

尝试在Nexus 4上运行此功能。

我的gradle构建文件:

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

现在,当我尝试运行应用程序时,我总是收到错误消息:

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)

1 个答案:

答案 0 :(得分:1)

我有同样的问题。它似乎与库没有被复制或在设备上正确的lib路径中找不到。

Fwiw我是从模拟器运行的(如果重要的话),但我真的卡住/沮丧