Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

LibGDX - Error reading file: uiskin.json

I found a few similar questions about this topic, but none helped me. I've downloaded the "uiskin.xxx" and the "default.fnt" files from Github to start the game with a few test assets, but there seems to be a problem with the uiskin.json file. All the files are in the android/assets/Skins folder.

This is the code where the json file is loaded:

public class Assets {
public static AssetManager manager = new AssetManager();
public static Skin menuSkin;

public static void queueLoading() {

    manager.load("Skins/uiskin.atlas", TextureAtlas.class);
    manager.load("Ressources/DemonHunter.jpg", Texture.class);
    manager.load("Ressources/DemonWarrior.jpg", Texture.class);
    manager.load("Ressources/WingedDemon.jpg", Texture.class);
    manager.load("Ressources/Viking.jpg", Texture.class);

}

public static void setMenuSkin() {

    if (menuSkin == null)
        menuSkin = new Skin(Gdx.files.internal("Skins/uiskin.json"),
                manager.get("Skins/uiskin.atlas", TextureAtlas.class));

}

public static boolean update() {
    return manager.update();
}
}

This is the json file:

{
com.badlogic.gdx.graphics.g2d.BitmapFont: { default-font: { file: Skins/default.fnt } },
com.badlogic.gdx.graphics.Color: {
    green: { a: 1, b: 0, g: 1, r: 0 },
    white: { a: 1, b: 1, g: 1, r: 1 },
    red: { a: 1, b: 0, g: 0, r: 1 },
    black: { a: 1, b: 0, g: 0, r: 0 },
},
com.badlogic.gdx.scenes.scene2d.ui.Skin$TintedDrawable: {
    dialogDim: { name: white, color: { r: 0, g: 0, b: 0, a: 0.45 } },
},
com.badlogic.gdx.scenes.scene2d.ui.Button$ButtonStyle: {
    default: { down: default-round-down, up: default-round },
    toggle: { down: default-round-down, checked: default-round-down, up: default-round }
},
com.badlogic.gdx.scenes.scene2d.ui.TextButton$TextButtonStyle: {
    default: { down: default-round-down, up: default-round, font: default-font, fontColor: white },
    toggle: { down: default-round-down, up: default-round, checked: default-round-down, font: default-font, fontColor: white, downFontColor: red }
},
com.badlogic.gdx.scenes.scene2d.ui.ScrollPane$ScrollPaneStyle: {
    default: { vScroll: default-scroll, hScrollKnob: default-round-large, background: default-rect, hScroll: default-scroll, vScrollKnob: default-round-large }
},
com.badlogic.gdx.scenes.scene2d.ui.SelectBox$SelectBoxStyle: {
    default: {
        font: default-font, fontColor: white, background: default-select,
        scrollStyle: default,
        listStyle: { font: default-font, selection: default-select-selection }
    }
},
com.badlogic.gdx.scenes.scene2d.ui.SplitPane$SplitPaneStyle: {
    default-vertical: { handle: default-splitpane-vertical },
    default-horizontal: { handle: default-splitpane }
},
com.badlogic.gdx.scenes.scene2d.ui.Window$WindowStyle: {
    default: { titleFont: default-font, background: default-window, titleFontColor: white },
    dialog: { titleFont: default-font, background: default-window, titleFontColor: white, stageBackground: dialogDim }
},
com.badlogic.gdx.scenes.scene2d.ui.ProgressBar$ProgressBarStyle: {
    default-horizontal: { background: default-slider, knob: default-slider-knob },
    default-vertical: { background: default-slider, knob: default-round-large }
},
com.badlogic.gdx.scenes.scene2d.ui.Slider$SliderStyle: {
    default-horizontal: { background: default-slider, knob: default-slider-knob },
    default-vertical: { background: default-slider, knob: default-round-large }
},
com.badlogic.gdx.scenes.scene2d.ui.Label$LabelStyle: {
    default: { font: default-font, fontColor: white }
},
com.badlogic.gdx.scenes.scene2d.ui.TextField$TextFieldStyle: {
    default: { selection: selection, background: textfield, font: default-font, fontColor: white, cursor: cursor }
},
com.badlogic.gdx.scenes.scene2d.ui.CheckBox$CheckBoxStyle: {
    default: { checkboxOn: check-on, checkboxOff: check-off, font: default-font, fontColor: white }
},
com.badlogic.gdx.scenes.scene2d.ui.List$ListStyle: {
    default: { fontColorUnselected: white, selection: selection, fontColorSelected: white, font: default-font }
},
com.badlogic.gdx.scenes.scene2d.ui.Touchpad$TouchpadStyle: {
    default: { background: default-pane, knob: default-round-large }
},
com.badlogic.gdx.scenes.scene2d.ui.Tree$TreeStyle: {
    default: { minus: tree-minus, plus: tree-plus, selection: default-select-selection }
},
com.badlogic.gdx.scenes.scene2d.ui.TextTooltip$TextTooltipStyle: {
    default: {
        label: { font: default-font, fontColor: white },
        background: default-pane
    }
},
}

I am not sure if the path at the beginning is correct, but I've tried a few different paths to be sure that that isn't the error.

And here is the error:

Exception in thread "LWJGL Application" com.badlogic.gdx.utils.SerializationException: Error reading file: Skins/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:82)
    at com.valhallagames.hfp.data.Assets.setMenuSkin(Assets.java:26)
    at com.valhallagames.hfp.screens.Splash.render(Splash.java:34)
    at com.badlogic.gdx.Game.render(Game.java:46)
    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: Skins/uiskin.json
    at com.badlogic.gdx.utils.Json.fromJson(Json.java:683)
    at com.badlogic.gdx.scenes.scene2d.ui.Skin.load(Skin.java:95)
    ... 6 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)
    ... 7 more
Caused by: com.badlogic.gdx.utils.reflect.ReflectionException: Class not found: com.badlogic.gdx.scenes.scene2d.ui.TextTooltip$TextTooltipStyle
    at com.badlogic.gdx.utils.reflect.ClassReflection.forName(ClassReflection.java:30)
    at com.badlogic.gdx.scenes.scene2d.ui.Skin$2.read(Skin.java:414)
    ... 11 more
Caused by: java.lang.ClassNotFoundException: com.badlogic.gdx.scenes.scene2d.ui.TextTooltip$TextTooltipStyle
    at java.net.URLClassLoader$1.run(Unknown Source)
    at java.net.URLClassLoader$1.run(Unknown Source)
    at java.security.AccessController.doPrivileged(Native Method)
    at java.net.URLClassLoader.findClass(Unknown Source)
    at java.lang.ClassLoader.loadClass(Unknown Source)
    at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
    at java.lang.ClassLoader.loadClass(Unknown Source)
    at java.lang.Class.forName0(Native Method)
    at java.lang.Class.forName(Unknown Source)
    at com.badlogic.gdx.utils.reflect.ClassReflection.forName(ClassReflection.java:28)
    ... 12 more

Thanks for every answer :). Cheers, Joshflux

like image 606
Joshflux Avatar asked Jul 22 '15 21:07

Joshflux


1 Answers

As suggested by James Skemp in the comments, open the uiskin.json file in your IDE and remove the following lines or similar from it and save the file:

com.badlogic.gdx.scenes.scene2d.ui.TextTooltip$TextTooltipStyle: {
    default: {
        label: { font: default-font, fontColor: white },
        background: default-pane
    }
}

Now it should work fine. I don't know why it works.

like image 60
Sunil Kumar Avatar answered Oct 21 '22 09:10

Sunil Kumar