TableLayout Test issues: filename and JSON parse error
7 posts
• Page 1 of 1
TableLayout Test issues: filename and JSON parse error
Hello, I searched the forums and issue tracker for this problem and the closest post I could find is here: viewtopic.php?f=11&t=20204&hilit=skin.
Like KingOfAllCunks, I am using the default libGDX skin pack files: uiskin.atlas, uiskin.json, uiskin.png, and default.fnt.
I got them from here: https://github.com/libgdx/libgdx/tree/m ... ssets/data.
I opened them in github, clicked 'RAW' and copied and pasted the raw data into notepad files and saved with matching file name endings (I had to delete a leading blank line in "uiskin.atlas" otherwise libGDX throws an error) .
I saved them in the "android/assets" folder.
The code I am running is from here: https://github.com/libgdx/libgdx/blob/m ... tTest.java. When I run the code, I get this error output:
When I paste the error message the "secret character" libGDX is appending to the front of "uiskin.png" doesn't even show up so here it is in a screen capture (it's right above the red arrow):

If I then copy and paste that sometimes invisible character from Android Studio's console output to my "uiskin.png" filename (it doesn't show up in Window 7's file explorer and, yes, adding this secret character lets libGDX find "uiskin.png" now) and run the code again I get this output:
Due to this error, I've tried a couple things to solve it:
1. I went through the libGDX wiki's Skin documentation to check my .json file against. I couldn't spot any missing brackets, commas, colons, etc.
2. Upgraded my libGDX ver. from 1.5.2 to 1.6.4 and built an entire new project using the new version and ran the TableLayoutTest.java code again.
3. I downloaded Android build-tools and sdk level 20 to match libGDX's preferred Android code (before, I was using the latest Android code base).
4. I created another new project from scratch after doing steps #2 and #3, downloaded a fresh "uiskin.png", opened it in a paint program and re-saved it as .png, and re-downloaded the rest of the default skin pack files (uiskin.atlas, default.fnt, uiskin.json).
Still getting the above error. In frustration, I deleted the default skin pack files out of the "android/assets" folder and ran the code. It somehow ran despite the files being deleted and here is the output (which is missing the labels and text fields):

I'm pretty confused at this point so any help is appreciated. Also, I apologize if I've missed this issue being covered somewhere else.
Like KingOfAllCunks, I am using the default libGDX skin pack files: uiskin.atlas, uiskin.json, uiskin.png, and default.fnt.
I got them from here: https://github.com/libgdx/libgdx/tree/m ... ssets/data.
I opened them in github, clicked 'RAW' and copied and pasted the raw data into notepad files and saved with matching file name endings (I had to delete a leading blank line in "uiskin.atlas" otherwise libGDX throws an error) .
I saved them in the "android/assets" folder.
The code I am running is from here: https://github.com/libgdx/libgdx/blob/m ... tTest.java. When I run the code, I get this error output:
- Code: Select all
Exception in thread "LWJGL Application" com.badlogic.gdx.utils.GdxRuntimeException: Couldn't load file: uiskin.png
at com.badlogic.gdx.graphics.Pixmap.<init>(Pixmap.java:140)
at com.badlogic.gdx.graphics.TextureData$Factory.loadFromFile(TextureData.java:98)
at com.badlogic.gdx.graphics.Texture.<init>(Texture.java:100)
at com.badlogic.gdx.graphics.g2d.TextureAtlas.load(TextureAtlas.java:244)
at com.badlogic.gdx.graphics.g2d.TextureAtlas.<init>(TextureAtlas.java:236)
at com.badlogic.gdx.graphics.g2d.TextureAtlas.<init>(TextureAtlas.java:231)
at com.badlogic.gdx.graphics.g2d.TextureAtlas.<init>(TextureAtlas.java:226)
at com.badlogic.gdx.graphics.g2d.TextureAtlas.<init>(TextureAtlas.java:216)
at com.badlogic.gdx.scenes.scene2d.ui.Skin.<init>(Skin.java:70)
at com.ststudios.table.TableGUI.create(TableGUI.java:27)
at com.badlogic.gdx.backends.lwjgl.LwjglApplication.mainLoop(LwjglApplication.java:143)
at com.badlogic.gdx.backends.lwjgl.LwjglApplication$1.run(LwjglApplication.java:120)
Caused by: com.badlogic.gdx.utils.GdxRuntimeException: File not found: uiskin.png (Internal)
at com.badlogic.gdx.files.FileHandle.read(FileHandle.java:136)
at com.badlogic.gdx.files.FileHandle.readBytes(FileHandle.java:222)
at com.badlogic.gdx.graphics.Pixmap.<init>(Pixmap.java:137)
... 11 more
When I paste the error message the "secret character" libGDX is appending to the front of "uiskin.png" doesn't even show up so here it is in a screen capture (it's right above the red arrow):

If I then copy and paste that sometimes invisible character from Android Studio's console output to my "uiskin.png" filename (it doesn't show up in Window 7's file explorer and, yes, adding this secret character lets libGDX find "uiskin.png" now) and run the code again I get this output:
- Code: Select all
Exception in thread "LWJGL Application" com.badlogic.gdx.utils.SerializationException: Error reading file: 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.ststudios.table.TableGUI.create(TableGUI.java:27)
at com.badlogic.gdx.backends.lwjgl.LwjglApplication.mainLoop(LwjglApplication.java:143)
at com.badlogic.gdx.backends.lwjgl.LwjglApplication$1.run(LwjglApplication.java:120)
Caused by: com.badlogic.gdx.utils.SerializationException: Error reading file: uiskin.json
at com.badlogic.gdx.utils.Json.fromJson(Json.java:683)
at com.badlogic.gdx.scenes.scene2d.ui.Skin.load(Skin.java:95)
... 4 more
Caused by: com.badlogic.gdx.utils.SerializationException: Error parsing file: uiskin.json
at com.badlogic.gdx.utils.JsonReader.parse(JsonReader.java:77)
at com.badlogic.gdx.utils.Json.fromJson(Json.java:681)
... 5 more
Caused by: com.badlogic.gdx.utils.SerializationException: Error parsing JSON on line 2 near: com.badlogic.gdx.graphics.g2d.BitmapFont: {
default-font: { file: 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,
at com.badlogic.gdx.utils.JsonReader.parse(JsonReader.java:548)
at com.badlogic.gdx.utils.JsonReader.parse(JsonReader.java:55)
at com.badlogic.gdx.utils.JsonReader.parse(JsonReader.java:75)
... 6 more
Due to this error, I've tried a couple things to solve it:
1. I went through the libGDX wiki's Skin documentation to check my .json file against. I couldn't spot any missing brackets, commas, colons, etc.
2. Upgraded my libGDX ver. from 1.5.2 to 1.6.4 and built an entire new project using the new version and ran the TableLayoutTest.java code again.
3. I downloaded Android build-tools and sdk level 20 to match libGDX's preferred Android code (before, I was using the latest Android code base).
4. I created another new project from scratch after doing steps #2 and #3, downloaded a fresh "uiskin.png", opened it in a paint program and re-saved it as .png, and re-downloaded the rest of the default skin pack files (uiskin.atlas, default.fnt, uiskin.json).
Still getting the above error. In frustration, I deleted the default skin pack files out of the "android/assets" folder and ran the code. It somehow ran despite the files being deleted and here is the output (which is missing the labels and text fields):

I'm pretty confused at this point so any help is appreciated. Also, I apologize if I've missed this issue being covered somewhere else.
Last edited by libbyjix on Mon Aug 17, 2015 8:34 pm, edited 2 times in total.
- libbyjix
- Posts: 18
- Joined: Fri May 15, 2015 5:07 pm
Re: TableLayout Test issues: filename and JSON parse error
How the hell can you mess up copy pasting a bunch of text? Oh i know, notepad is useless.
Go here https://github.com/libgdx/libgdx/blob/m ... iskin.json , click raw, right click -> save as. Rinse repeat for other files. Post the loading code.
Go here https://github.com/libgdx/libgdx/blob/m ... iskin.json , click raw, right click -> save as. Rinse repeat for other files. Post the loading code.
Looking for a freelancer? PM me!
Check out libgdx discord server!
Check out libgdx discord server!
- evilentity
- Posts: 4867
- Joined: Wed Aug 24, 2011 6:37 am
Re: TableLayout Test issues: filename and JSON parse error
Thank you for responding. My output is now the same as KingOfAllCunks' post here (3rd post down): viewtopic.php?f=11&t=20204&hilit=skin
If by this you mean the code I'm running to get the output, I'm just using the code from TableLayoutTest.java: https://github.com/libgdx/libgdx/blob/master/tests/gdx-tests/src/com/badlogic/gdx/tests/TableLayoutTest.java. The only thing I changed is the classname to match my .java file name.
As I stated previously, I am using the latest libGDX version, 1.6.4. And, to be sure, I created a new project from scratch using the latest libGDX jar file to use with the files I downloaded using your suggested method. According to the responses to KingOfAllCunk's post, this tool tips error is only supposed to happen in versions before 1.6.4, right?
Also, as a side tangent, what's wrong with Notepad? It doesn't save any formatting metadata and many "quick start" guides to trying out a programming language usually suggest pasting code to be compiled directly into notepad and saving with appropriate filename extension. Is there some character set/encoding differences that Notepad has vs what libGDX developers use? Notepad can encode as ANSI, Unicode, Unicode big endian, or UTF-8 so I'm assuming the mismatch stems from there.
- Code: Select all
Exception in thread "LWJGL Application" com.badlogic.gdx.utils.SerializationException: Error reading file: 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.ststudios.table.TableGUI.create(TableGUI.java:27)
at com.badlogic.gdx.backends.lwjgl.LwjglApplication.mainLoop(LwjglApplication.java:143)
at com.badlogic.gdx.backends.lwjgl.LwjglApplication$1.run(LwjglApplication.java:120)
Caused by: com.badlogic.gdx.utils.SerializationException: Error reading file: uiskin.json
at com.badlogic.gdx.utils.Json.fromJson(Json.java:683)
at com.badlogic.gdx.scenes.scene2d.ui.Skin.load(Skin.java:95)
... 4 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)
... 5 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)
... 9 more
Caused by: java.lang.ClassNotFoundException: com.badlogic.gdx.scenes.scene2d.ui.TextTooltip$TextTooltipStyle
at java.net.URLClassLoader.findClass(URLClassLoader.java:381)
at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:331)
at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Class.java:264)
at com.badlogic.gdx.utils.reflect.ClassReflection.forName(ClassReflection.java:28)
... 10 more
Post the loading code.
If by this you mean the code I'm running to get the output, I'm just using the code from TableLayoutTest.java: https://github.com/libgdx/libgdx/blob/master/tests/gdx-tests/src/com/badlogic/gdx/tests/TableLayoutTest.java. The only thing I changed is the classname to match my .java file name.
- Code: Select all
public class TableGUI extends InputAdapter implements ApplicationListener {
Stage stage;
public void create () {
stage = new Stage();
Gdx.input.setInputProcessor(stage);
Skin skin = new Skin(Gdx.files.internal("uiskin.json"));
Label nameLabel = new Label("Name:", skin);
TextField nameText = new TextField("", skin);
Label addressLabel = new Label("Address:", skin);
TextField addressText = new TextField("", skin);
Table table = new Table();
stage.addActor(table);
table.setSize(260, 195);
table.setPosition(190, 142);
// table.align(Align.right | Align.bottom);
table.debug();
TextureRegion upRegion = skin.getRegion("default-slider-knob");
TextureRegion downRegion = skin.getRegion("default-slider-knob");
BitmapFont buttonFont = skin.getFont("default-font");
TextButton button = new TextButton("Button 1", skin);
button.addListener(new InputListener() {
public boolean touchDown (InputEvent event, float x, float y, int pointer, int button) {
System.out.println("touchDown 1");
return false;
}
});
table.add(button);
// table.setTouchable(Touchable.disabled);
Table table2 = new Table();
stage.addActor(table2);
table2.setFillParent(true);
table2.bottom();
TextButton button2 = new TextButton("Button 2", skin);
button2.addListener(new ChangeListener() {
public void changed (ChangeEvent event, Actor actor) {
System.out.println("2!");
}
});
button2.addListener(new InputListener() {
public boolean touchDown (InputEvent event, float x, float y, int pointer, int button) {
System.out.println("touchDown 2");
return false;
}
});
table2.add(button2);
}
public void render () {
Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT);
stage.act(Gdx.graphics.getDeltaTime());
stage.draw();
}
public void resize (int width, int height) {
stage.getViewport().update(width, height, true);
}
public void dispose () {
stage.dispose();
}
public void resume(){}
public void pause(){}
}
As I stated previously, I am using the latest libGDX version, 1.6.4. And, to be sure, I created a new project from scratch using the latest libGDX jar file to use with the files I downloaded using your suggested method. According to the responses to KingOfAllCunk's post, this tool tips error is only supposed to happen in versions before 1.6.4, right?
Also, as a side tangent, what's wrong with Notepad? It doesn't save any formatting metadata and many "quick start" guides to trying out a programming language usually suggest pasting code to be compiled directly into notepad and saving with appropriate filename extension. Is there some character set/encoding differences that Notepad has vs what libGDX developers use? Notepad can encode as ANSI, Unicode, Unicode big endian, or UTF-8 so I'm assuming the mismatch stems from there.
Last edited by libbyjix on Thu Aug 13, 2015 4:19 pm, edited 1 time in total.
- libbyjix
- Posts: 18
- Joined: Fri May 15, 2015 5:07 pm
Re: TableLayout Test issues: filename and JSON parse error
- Code: Select all
Class not found: com.badlogic.gdx.scenes.scene2d.ui.TextTooltip$TextTooltipStyle
That means you didnt update to 1.6.4. How did you update? You can just remove that style and it will probably work.
Looking for a freelancer? PM me!
Check out libgdx discord server!
Check out libgdx discord server!
- evilentity
- Posts: 4867
- Joined: Wed Aug 24, 2011 6:37 am
Re: TableLayout Test issues: filename and JSON parse error
I went to: https://libgdx.badlogicgames.com/download.html and used the setup app. When I run the jar file, it says the libGDX version is 1.6.4.
I went ahead and removed the class and no error messages now. So I'll be happy with that
Also, comparing my output to: https://github.com/libgdx/libgdx/wiki/Table#quickstart, I realized that the example code I got from github doesn't add the label/text fields to the table as the code in the quickstart link does, which is why I wasn't getting this output:

Fixed that now. Thanks again for your help.
For anyone else reading, I added these lines from the quickstart link above to TableLayoutTest.java code after the table object is instantiated:
Now my output looks like this:

Much better
I went ahead and removed the class and no error messages now. So I'll be happy with that


Fixed that now. Thanks again for your help.
For anyone else reading, I added these lines from the quickstart link above to TableLayoutTest.java code after the table object is instantiated:
- Code: Select all
table.add(nameLabel);
table.add(nameText).width(100);
table.row();
table.add(addressLabel);
table.add(addressText).width(100);
table.row();
Now my output looks like this:

Much better

- libbyjix
- Posts: 18
- Joined: Fri May 15, 2015 5:07 pm
Re: TableLayout Test issues: filename and JSON parse error
And what did it say when you created the project? Running the setup doesnt update anything. Go to build.gradle and update the thing...
Looking for a freelancer? PM me!
Check out libgdx discord server!
Check out libgdx discord server!
- evilentity
- Posts: 4867
- Joined: Wed Aug 24, 2011 6:37 am
Re: TableLayout Test issues: filename and JSON parse error
After I downloaded the 1.6.4 jar (as I mentioned in my original post) and built a new project with it the project generator took around 4 minutes to build because it was downloading all the updated code through maven. That's what the output said anyway. The download link I posted also says: "LibGDX uses a Gradle based setup application which will download all that's required automatically!" So I thought all of that indicated that I was running the latest libGDX version whenever I generated a new project through the jar file. Is that not correct?
*edit* - I checked my build.gradle file and it says that the libGDX version is 1.6.4 as well.
*edit* - I checked my build.gradle file and it says that the libGDX version is 1.6.4 as well.
- libbyjix
- Posts: 18
- Joined: Fri May 15, 2015 5:07 pm
7 posts
• Page 1 of 1
Return to Libgdx