我正在开发一个使用Universal Tween Engine的Libgdx项目。我已按照此页面https://github.com/libgdx/libgdx/wiki/Universal-Tween-Engine上的所有步骤将Universal Tween Engine库安装到项目中。
完成所有这些步骤后,该项目可以在我的笔记本电脑上构建和运行(Android和桌面均可),来自tween引擎的动画完美地工作。
然而,在我的桌面电脑上,每当我尝试运行桌面应用程序时,都会抛出NoClassDefFoundException,该异常在TweenAccessor类上被抛出,该类是Universal Tween Engine的一部分。应用程序编译正确,我可以通过Ctrl单击它无法找到的类,并打开该类的源代码,因此我知道IDE的某个部分至少能够找到该类。在源代码编辑器中,没有任何Library类的红色下划线错误。有趣的是,在我的桌面电脑上,我可以运行Android应用程序,它不会崩溃,并且动画完美地工作。只有桌面版本不能工作。
在尝试解决这个问题时,我遇到了很多建议切换到“项目”视图,找到jar文件,右键单击它们并选择
但是我的问题是,在我的台式电脑上右键单击时,上下文菜单中缺少
在右键单击jar文件时,“添加为库”选项是否显示取决于什么?
我在我的桌面PC上必须做什么才能正确使用Universal Tween Engine库jar?
编辑:gradle.build的相关部分。
完成所有这些步骤后,该项目可以在我的笔记本电脑上构建和运行(Android和桌面均可),来自tween引擎的动画完美地工作。
然而,在我的桌面电脑上,每当我尝试运行桌面应用程序时,都会抛出NoClassDefFoundException,该异常在TweenAccessor类上被抛出,该类是Universal Tween Engine的一部分。应用程序编译正确,我可以通过Ctrl单击它无法找到的类,并打开该类的源代码,因此我知道IDE的某个部分至少能够找到该类。在源代码编辑器中,没有任何Library类的红色下划线错误。有趣的是,在我的桌面电脑上,我可以运行Android应用程序,它不会崩溃,并且动画完美地工作。只有桌面版本不能工作。
在尝试解决这个问题时,我遇到了很多建议切换到“项目”视图,找到jar文件,右键单击它们并选择
添加为库
。我以前在其他项目中也不得不这样做,它确实对我有用。但是我的问题是,在我的台式电脑上右键单击时,上下文菜单中缺少
添加为库
选项:
我已经尝试清理项目。 我甚至完全卸载了Android Studio,并下载了一个新版本并进行了安装。 在执行此操作后仍然会得到相同的结果。在右键单击jar文件时,“添加为库”选项是否显示取决于什么?
我在我的桌面PC上必须做什么才能正确使用Universal Tween Engine库jar?
编辑:gradle.build的相关部分。
project(":desktop") {
apply plugin: "java"
dependencies {
compile project(":core")
compile "com.badlogicgames.gdx:gdx-backend-lwjgl:$gdxVersion"
compile "com.badlogicgames.gdx:gdx-platform:$gdxVersion:natives-desktop"
compile "com.badlogicgames.gdx:gdx-box2d-platform:$gdxVersion:natives-desktop"
compile fileTree(dir: '../libs', include: '*.jar') // This one is not listed but I added anyway
}
}
//...
project(":android") {
apply plugin: "android"
configurations { natives }
dependencies {
compile project(":core")
compile "com.badlogicgames.gdx:gdx-backend-android:$gdxVersion"
natives "com.badlogicgames.gdx:gdx-platform:$gdxVersion:natives-armeabi"
natives "com.badlogicgames.gdx:gdx-platform:$gdxVersion:natives-armeabi-v7a"
natives "com.badlogicgames.gdx:gdx-platform:$gdxVersion:natives-x86"
compile "com.badlogicgames.gdx:gdx-box2d:$gdxVersion"
natives "com.badlogicgames.gdx:gdx-box2d-platform:$gdxVersion:natives-armeabi"
natives "com.badlogicgames.gdx:gdx-box2d-platform:$gdxVersion:natives-armeabi-v7a"
natives "com.badlogicgames.gdx:gdx-box2d-platform:$gdxVersion:natives-x86"
compile fileTree(dir: '../libs', include: '*.jar')
}
}
//...
project(":core") {
apply plugin: "java"
dependencies {
compile "com.badlogicgames.gdx:gdx:$gdxVersion"
compile "com.badlogicgames.gdx:gdx-box2d:$gdxVersion"
compile fileTree(dir: '../libs', include: '*.jar')
}
}
我的项目结构
project_root_dir/
android/
core/
desktop/
html/
ios/
libs/
tween-engine-api.jar
tween-engine-api-sources.jar
compile fileTree(dir: '../libs', include: '*.jar')
- Knossos