我正在使用these instructions过渡到我的libgdx项目的maven。但我的项目需要freetype,我对如何添加依赖项感到困惑:
Caused by: com.badlogic.gdx.utils.GdxRuntimeException: Unable to read file for extraction: libgdx-freetype64.so
at com.badlogic.gdx.utils.SharedLibraryLoader.readFile(SharedLibraryLoader.java:119)
at com.badlogic.gdx.utils.SharedLibraryLoader.loadFile(SharedLibraryLoader.java:231)
at com.badlogic.gdx.utils.SharedLibraryLoader.load(SharedLibraryLoader.java:108)
... 7 more
这是我的desktop / pom.xml:
<dependencies>
<dependency>
<groupId>com.autonomousgames.starcycle</groupId>
<artifactId>starcycle-core</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>com.badlogicgames.gdx</groupId>
<artifactId>gdx</artifactId>
<version>${gdx.version}</version>
</dependency>
<dependency>
<groupId>com.badlogicgames.gdx</groupId>
<artifactId>gdx-freetype-platform</artifactId>
<version>${gdx.version}</version>
</dependency>
<dependency>
<groupId>com.badlogicgames.gdx</groupId>
<artifactId>gdx-freetype</artifactId>
<version>${gdx.version}</version>
</dependency>
<dependency>
<groupId>com.badlogicgames.gdx</groupId>
<artifactId>gdx-backend-lwjgl</artifactId>
<version>${gdx.version}</version>
</dependency>
<dependency>
<groupId>com.badlogicgames.gdx</groupId>
<artifactId>gdx-platform</artifactId>
<version>${gdx.version}</version>
<classifier>natives-desktop</classifier>
</dependency>
编辑:当我运行“mvn clean install -Pdesktop”时,我得到以下内容:
main:
[java] Exception in thread "LWJGL Application" com.badlogic.gdx.utils.GdxRuntimeException: java.lang.ExceptionInInitializerError
[java] at com.badlogic.gdx.backends.lwjgl.LwjglApplication$1.run(LwjglApplication.java:120)
[java] Caused by: java.lang.ExceptionInInitializerError
[java] at com.autonomousgames.starcycle.core.screens.SplashScreen.<init>(SplashScreen.java:20)
[java] at com.autonomousgames.starcycle.core.StarCycle.create(StarCycle.java:40)
[java] at com.badlogic.gdx.backends.lwjgl.LwjglApplication.mainLoop(LwjglApplication.java:136)
[java] at com.badlogic.gdx.backends.lwjgl.LwjglApplication$1.run(LwjglApplication.java:114)
[java] Caused by: com.badlogic.gdx.utils.GdxRuntimeException: Couldn't load shared library 'libgdx-freetype64.so' for target: Linux, 64-bit
[java] at com.badlogic.gdx.utils.SharedLibraryLoader.load(SharedLibraryLoader.java:110)
[java] at com.badlogic.gdx.graphics.g2d.freetype.FreeType.initFreeType(FreeType.java:541)
[java] at com.badlogic.gdx.graphics.g2d.freetype.FreeTypeFontGenerator.<init>(FreeTypeFontGenerator.java:101)
[java] at com.autonomousgames.starcycle.core.Texturez.<clinit>(Texturez.java:261)
[java] ... 4 more
[java] Caused by: com.badlogic.gdx.utils.GdxRuntimeException: Unable to read file for extraction: libgdx-freetype64.so
[java] at com.badlogic.gdx.utils.SharedLibraryLoader.readFile(SharedLibraryLoader.java:119)
[java] at com.badlogic.gdx.utils.SharedLibraryLoader.loadFile(SharedLibraryLoader.java:231)
[java] at com.badlogic.gdx.utils.SharedLibraryLoader.load(SharedLibraryLoader.java:108)
[java] ... 7 more
答案 0 :(得分:3)
解决方案是将分类器添加到任何特定于平台的罐子中,包括“平台”一词表示:
<dependency>
<groupId>com.badlogicgames.gdx</groupId>
<artifactId>gdx-freetype-platform</artifactId>
<version>${gdx.version}</version>
<classifier>natives-desktop</classifier> ### Here
</dependency>
<dependency>
<groupId>com.badlogicgames.gdx</groupId>
<artifactId>gdx-backend-lwjgl</artifactId>
<version>${gdx.version}</version>
</dependency>
<dependency>
<groupId>com.badlogicgames.gdx</groupId>
<artifactId>gdx-platform</artifactId>
<version>${gdx.version}</version>
<classifier>natives-desktop</classifier>
</dependency>