我正在尝试将esotericsoftware“Kryo”中的lib添加到桌面和Android模块上的libGDX项目中。我正在使用Intellij。
我尝试了什么:
compile "com.esotericsoftware:kryo:3.0.3"
编译桌面模块后得到的结果:
Exception in thread "LWJGL Application" com.badlogic.gdx.utils.GdxRuntimeException: java.lang.NoClassDefFoundError: org/objenesis/strategy/InstantiatorStrategy
at com.badlogic.gdx.backends.lwjgl.LwjglApplication$1.run(LwjglApplication.java:131)
Caused by: java.lang.NoClassDefFoundError: org/objenesis/strategy/InstantiatorStrategy
at com.projectbeta.deepdarkness.screens.MenuScreen.show(MenuScreen.java:18)
at com.badlogic.gdx.Game.setScreen(Game.java:61)
at com.projectbeta.deepdarkness.DeepDarkness.create(DeepDarkness.java:16)
at com.badlogic.gdx.backends.lwjgl.LwjglApplication.mainLoop(LwjglApplication.java:147)
at com.badlogic.gdx.backends.lwjgl.LwjglApplication$1.run(LwjglApplication.java:124)
Caused by: java.lang.ClassNotFoundException: org.objenesis.strategy.InstantiatorStrategy
at java.net.URLClassLoader.findClass(URLClassLoader.java:381)
at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:331)
at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
... 5 more
答案 0 :(得分:1)
刚刚测试过并且可以正常运行,将其粘贴到项目的根gradle.build
中(不是某些特定于模块的)并重新同步。
project(":core") {
apply plugin: "java"
dependencies {
......
compile group: 'com.esotericsoftware', name: 'kryo', version: '3.0.3'
}
}
project(":desktop") {
apply plugin: "java"
dependencies {
compile project(":core")
.......
compile group: 'com.esotericsoftware', name: 'kryo', version: '3.0.3'
}
}
project(":android") {
apply plugin: "android"
configurations { natives }
dependencies {
compile project(":core")
......
compile group: 'com.esotericsoftware', name: 'kryo', version: '3.0.3'
}
}