I am working on a Libgdx project that uses the Universal Tween Engine. I have followed all of the steps on this page: https://github.com/libgdx/libgdx/wiki/Universal-Tween-Engine to install the Universal Tween Engine library into my project.
After completing all of these steps the project will build and run fine (both Android and Desktop) on my laptop PC, and the animations coming from the tween engine work perfectly.
However on my desktop computer whenever I try to run the desktop application it crashes with NoClassDefFoundException being thrown on the TweenAccessor class which is part of the Universal Tween Engine. The application compiles correctly and I can ctrl-click on the Class that it is saying it cant find and it opens up the source code of that class so I know at least some part of the IDE is finding this class. There is no red underline errors on any of the Library classes in the source code editor. Interestingly on my desktop computer I can run the android application and it does not crash, and the animations work perfectly. Only the Desktop version will not work.
In trying to troubleshoot this I've run accross many things that say to switch to 'Project' view find the jar files, right click them and choose Add as a Library
I've had to do this in the past on other projects and it did indeed work for me.
But my problem is the Add as a Library
option is missing from the context menu when I right click it on my desktop PC:
I've tried cleaning the project. I even completely uninstall Android Studio and downloaded a new copy and Installed it. Still get the same results after doing this.
What determines whether or not the "Add as a Library" option will show up in the context menu when right clicking on a jar file?
What do I have to do on my desktop PC to get it to properly use the Universal Tween Engine library jar?
EDIT: Relevant sections of 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')
}
}
My Project Structure
project_root_dir/
android/
core/
desktop/
html/
ios/
libs/
tween-engine-api.jar
tween-engine-api-sources.jar
I would just add as dependency just this line:
compile files('../libs/tween-engine-api.jar')
That line above should replace this line:
compile fileTree(dir: '../libs', include: '*.jar')
I could imagine that the source code file is breaking something. In general I would avoid to import multiple jars at once, I would always select them by hand.
As an alternative idea did you try the points 6 and 7 from the readme file?
Adding this in your dependency section:
compile "aurelienribon:tweenengine:6.3.3"
compile "aurelienribon:tweenengine:6.3.3:sources"
And add this two maven repositoried to your build.gradle file in the project root:
maven { url "https://oss.sonatype.org/content/repositories/snapshots/" }
maven { url "https://oss.sonatype.org/content/repositories/releases/" }
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With