无法加载Libgdx gdx64.dll

时间:2018-11-15 15:07:17

标签: java junit libgdx

我正在尝试使用JUnit和以下教程在libgdx项目上运行一些测试:http://manabreak.eu/java/2016/10/21/unittesting-libgdx.html

我将所有依赖项添加到模块中,但是出现以下错误:

com.badlogic.gdx.utils.GdxRuntimeException:无法为目标:Windows 10(64位)加载共享库“ gdx64.dll”

at com.badlogic.gdx.utils.SharedLibraryLoader.load(SharedLibraryLoader.java:125)
at com.badlogic.gdx.utils.GdxNativesLoader.load(GdxNativesLoader.java:33)
at com.badlogic.gdx.backends.headless.HeadlessNativesLoader.load(HeadlessNativesLoader.java:24)
at com.badlogic.gdx.backends.headless.HeadlessApplication.<init>(HeadlessApplication.java:66)
at com.badlogic.gdx.backends.headless.HeadlessApplication.<init>(HeadlessApplication.java:59)
at Model.GameTest.init(GameTest.java:20)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:50)
at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12)
at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:47)
at org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java:24)
at org.junit.internal.runners.statements.RunAfters.evaluate(RunAfters.java:27)
at org.junit.runners.ParentRunner.run(ParentRunner.java:363)
at org.junit.runner.JUnitCore.run(JUnitCore.java:137)
at com.intellij.junit4.JUnit4IdeaTestRunner.startRunnerWithArgs(JUnit4IdeaTestRunner.java:68)
at com.intellij.rt.execution.junit.IdeaTestRunner$Repeater.startRunnerWithArgs(IdeaTestRunner.java:47)
at com.intellij.rt.execution.junit.JUnitStarter.prepareStreamsAndStart(JUnitStarter.java:242)
at com.intellij.rt.execution.junit.JUnitStarter.main(JUnitStarter.java:70)

原因:com.badlogic.gdx.utils.GdxRuntimeException:无法读取文件以进行提取:gdx64.dll     在com.badlogic.gdx.utils.SharedLibraryLoader.readFile(SharedLibraryLoader.java:133)     在com.badlogic.gdx.utils.SharedLibraryLoader.loadFile(SharedLibraryLoader.java:289)     在com.badlogic.gdx.utils.SharedLibraryLoader.load(SharedLibraryLoader.java:121)     ...另外20个

很显然,HeadlessApplication无法访问gdx64.dll,但我不知道如何解决该问题。 我还尝试添加gdx.jar,gdx-backend-lwjgl-natives.jar,gdx-natives,但是没有任何效果。当我将gdx-setup.jar用于新项目时,也会发生类似的问题。

非常感谢您的帮助!

2 个答案:

答案 0 :(得分:0)

我通过将以下依赖项添加到主build.gradle“核心”项目中来解决此问题:

api "com.badlogicgames.gdx:gdx-platform:$gdxVersion:natives-desktop"

enter image description here

答案 1 :(得分:0)

我在尝试从 libgdx 项目运行 launchTestLwjgl3 gradle 任务时遇到了这个错误。使用 ./gradlew fetchNatives 获取原生二进制文件为我解决了这个问题。

https://libgdx.com/dev/from-source/