LibGDX - Error reading file: uiskin.json
I found several similar questions on this topic, but none helped me. I downloaded the "uiskin.xxx" and "default.fnt" files from Github to start playing with a few test assets, but there seems to be a problem with the uiskin.json file. All files are located in 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'm not sure if the path is correct at the beginning, but I've tried several different paths to make sure it's not a bug.
And here's 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
source to share
As suggested by James Sump in the comments, open the uiskin.json file in your IDE and remove the following lines or similar files from it and save the file:
com.badlogic.gdx.scenes.scene2d.ui.TextTooltip$TextTooltipStyle: {
default: {
label: { font: default-font, fontColor: white },
background: default-pane
}
}
It should now work fine. I don't know why this works.
source to share
Do you have an atlas file? If not, you should. And they are used like this:
FileHandle fileHandle = Gdx.files.internal("pathToMyJsonFile/fileNameForMyJson.json");
FileHandle atlasFile = fileHandle.sibling("fileNameForMyJson.atlas");
if (atlasFile.exists()) {
Gdx.app.log("MyGame", "atlas file is loaded");
skin.addRegions(new TextureAtlas(atlasFile));
} else {
Gdx.app.log("MyGame", "atlas file is NOT loaded");
}
The Atlas file defines the locations of your textures in the png file. You can find the API for TextureAtlas here .
Your json file has a link to the default panel. Here is NOT . Atlas file where it should be defined.
Hope this helps. =]
source to share