gpt4 book ai didi

java - Box2d 不会使用 LibsGDX 和 Gradle 进行加载

转载 作者:行者123 更新时间:2023-12-01 12:47:18 26 4
gpt4 key购买 nike

我的设置: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)

最佳答案

我也有同样的问题。这似乎是因为库没有被复制或者在设备上的正确库路径中找不到。

Fwiw,我正在从模拟器运行这个(如果这很重要),但我真的陷入困境/沮丧

关于java - Box2d 不会使用 LibsGDX 和 Gradle 进行加载,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24575163/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com