1

I am new to using the Skin element in LibGdx. My objective is just to perform simple Skin usage with changing the default font type of every element. However, it keeps giving me errors.

My main code:

public class SettingWindow{        
    Skin skin;

    public SettingWindow(){
        skin = new Skin(Gdx.files.internal("UISkin.json"));
    }
}

My json code:

{  com.badlogic.gdx.graphics.g2d.BitmapFont: { default-font: { file: windowText.fnt }}

My error:

 `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 Scene.TimerSettingWindow.<init>(TimerSettingWindow.java:40)
    at Scene.Hud.<init>(Hud.java:62)
    at Screens.MainScreen.<init>(MainScreen.java:42)
    at com.aipetgame.AiPetGame.create(AiPetGame.java:19)
    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)
    ... 7 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)
    ... 8 more           
Caused by: com.badlogic.gdx.utils.GdxRuntimeException: File not found: UISkin.json (Internal)
    at com.badlogic.gdx.files.FileHandle.read(FileHandle.java:136)
    at com.badlogic.gdx.files.FileHandle.reader(FileHandle.java:163)
    at com.badlogic.gdx.utils.JsonReader.parse(JsonReader.java:75)
    ... 9 more  `

I store everything in android/assets folder. Please help..

( I was trying to follow this tutorial https://www.youtube.com/watch?v=ELkqiMpvMLA )

Jankapunkt
  • 8,128
  • 4
  • 30
  • 59
Frankey
  • 324
  • 2
  • 13
  • Possible duplicate of ["File not found" when running new LibGDX project](https://stackoverflow.com/questions/22822767/file-not-found-when-running-new-libgdx-project) – Code-Apprentice Jan 14 '18 at 16:34
  • Create a new LibGDX project and try to run it. Do you get the same error? If so, see the link above for the fix. – Code-Apprentice Jan 14 '18 at 16:35
  • Will try it and confirm again later. Thanks – Frankey Jan 14 '18 at 16:48
  • 1
    My problem solved by restart the whole android studio, and recreate the json file. Have no clues about the reasons why but will continue my project anyway. Thanks. – Frankey Jan 15 '18 at 03:35

0 Answers0