0

I'm trying to run the desktop version of my LibGDX project, but getting following error ..

Exception in thread "LWJGL Application" com.badlogic.gdx.utils.SerializationException: Error reading file: ui/uiskin.json
    at com.badlogic.gdx.scenes.scene2d.ui.Skin.load(Skin.java:97)
    at com.badlogic.gdx.scenes.scene2d.ui.Skin.<init>(Skin.java:74)
    at com.mygdx.game.MainMenu.show(MainMenu.java:51)
    at com.badlogic.gdx.Game.setScreen(Game.java:61)
    at com.mygdx.game.Splash$1.run(Splash.java:48)
    at com.badlogic.gdx.scenes.scene2d.actions.RunnableAction.run(RunnableAction.java:42)
    at com.badlogic.gdx.scenes.scene2d.actions.RunnableAction.act(RunnableAction.java:32)
    at com.badlogic.gdx.scenes.scene2d.actions.SequenceAction.act(SequenceAction.java:65)
    at com.badlogic.gdx.scenes.scene2d.Actor.act(Actor.java:95)
    at com.badlogic.gdx.scenes.scene2d.Group.act(Group.java:49)
    at com.badlogic.gdx.scenes.scene2d.Stage.act(Stage.java:223)
    at com.badlogic.gdx.scenes.scene2d.Stage.act(Stage.java:186)
    at com.mygdx.game.Splash.render(Splash.java:29)
    at com.badlogic.gdx.Game.render(Game.java:46)
    at com.mygdx.game.ColorCatch.render(ColorCatch.java:19)
    at com.badlogic.gdx.backends.lwjgl.LwjglApplication.mainLoop(LwjglApplication.java:215)
    at com.badlogic.gdx.backends.lwjgl.LwjglApplication$1.run(LwjglApplication.java:120)
Caused by: com.badlogic.gdx.utils.SerializationException: Error reading file: ui/uiskin.json
    at com.badlogic.gdx.utils.Json.fromJson(Json.java:683)
    at com.badlogic.gdx.scenes.scene2d.ui.Skin.load(Skin.java:95)
    ... 16 more
Caused by: com.badlogic.gdx.utils.SerializationException: 
    at com.badlogic.gdx.scenes.scene2d.ui.Skin$2.read(Skin.java:416)
    at com.badlogic.gdx.scenes.scene2d.ui.Skin$2.read(Skin.java:410)
    at com.badlogic.gdx.utils.Json.readValue(Json.java:867)
    at com.badlogic.gdx.scenes.scene2d.ui.Skin$1.readValue(Skin.java:404)
    at com.badlogic.gdx.utils.Json.fromJson(Json.java:681)
    ... 17 more
Caused by: com.badlogic.gdx.utils.reflect.ReflectionException: Class not found: com.badlogic.gdx.scenes.scene2d.ui.Tooltip$TooltipStyle
    at com.badlogic.gdx.utils.reflect.ClassReflection.forName(ClassReflection.java:30)
    at com.badlogic.gdx.scenes.scene2d.ui.Skin$2.read(Skin.java:414)
    ... 21 more
Caused by: java.lang.ClassNotFoundException: com.badlogic.gdx.scenes.scene2d.ui.Tooltip$TooltipStyle
    at java.net.URLClassLoader$1.run(URLClassLoader.java:366)
    at java.net.URLClassLoader$1.run(URLClassLoader.java:355)
    at java.security.AccessController.doPrivileged(Native Method)
    at java.net.URLClassLoader.findClass(URLClassLoader.java:354)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:425)
    at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:308)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:358)
    at java.lang.Class.forName0(Native Method)
    at java.lang.Class.forName(Class.java:191)
    at com.badlogic.gdx.utils.reflect.ClassReflection.forName(ClassReflection.java:28)

Project structure is the following ..

rob@work:~/git/test$ ls
android       core     gradle             gradlew      ios   local.properties
build.gradle  desktop  gradle.properties  gradlew.bat  libs  settings.gradle
rob@work:~/git/test$ ls android/assets/ui/
default.fnt   uiskin.atlas   uiskin.json   uiskin.png

Simplified version of MainMenu ..

public class MainMenu implements Screen {

    private Stage stage = new Stage();
    private TextureAtlas atlas;
    private Skin skin;
    private Button quit;

    public MainMenu() {}

    @Override
    public void render(float delta) {
        Gdx.gl.glClearColor(0, 0, 0, 1);
        Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT);

        stage.act(delta);
        stage.draw();
    }

    @Override
    public void show() {

        atlas = new TextureAtlas("ui/uiskin.atlas");
        skin = new Skin(Gdx.files.internal("ui/uiskin.json"));
        skin.addRegions(atlas);
    }

    @Override
    public void resize(int width, int height) {

        TextButtonStyle styleQuit = new TextButtonStyle();
        styleQuit.up = skin.getDrawable("8layer");
    }
}
bobbyrne01
  • 6,295
  • 19
  • 80
  • 150

2 Answers2

1

Did you update libgdx to version 1.6.4? Tooltips ware just added, if your skin file is missing them it will crash. Check the tests in libgdx repo to see how it looks like.

PiotrJ
  • 151
  • 4
0

Check your uiskin.atlas file. Probably it does not contain any definition for Tooltip. Just remove the block for com.badlogic.gdx.scenes.scene2d.ui.Tooltip$TooltipStyle from the uiskin.json and test. I am confident this is what is causing the issue. If you are not using any tooltip, then you can probably remove that block from the json permanently and use it. It should work. If you need it, then you will have to add required entry for the tooltip in the atlas file.

Josh Crozier
  • 233,099
  • 56
  • 391
  • 304
jdkraftz
  • 71
  • 1
  • 3