2

I've been working on a LIBGDX game for a while and last week I updated my Android Studio to Version 2.1.2. After the update I started getting the java.lang.ExceptionInInitializerError when the render method in the screen class tries to draw a static image which was called from a different class. " batcher.begin(); batcher.draw(Assets.rockWall, 0, 0, 160, 90); "

Here is my error log:

07-24 12:12:10.702 9442-9489/? E/AndroidRuntime: FATAL EXCEPTION: GLThread 32587 Process: com.dotabmot.game, PID: 9442 java.lang.ExceptionInInitializerError at com.dotabmot.game.StartMenuScreen.render(StartMenuScreen.java:108) at com.badlogic.gdx.Game.render(Game.java:46) at com.badlogic.gdx.backends.android.AndroidGraphics.onDrawFrame(AndroidGraphics.java:474) at android.opengl.GLSurfaceView$GLThread.guardedRun(GLSurfaceView.java:1531) at android.opengl.GLSurfaceView$GLThread.run(GLSurfaceView.java:1248) Caused by: com.badlogic.gdx.utils.GdxRuntimeException: Couldn't load file: trollWalk1.png at com.badlogic.gdx.graphics.Pixmap.(Pixmap.java:148) at com.badlogic.gdx.graphics.TextureData$Factory.loadFromFile(TextureData.java:98) at com.badlogic.gdx.graphics.Texture.(Texture.java:100) at com.badlogic.gdx.graphics.Texture.(Texture.java:92) at com.dotabmot.game.Assets.(Assets.java:112) at com.dotabmot.game.StartMenuScreen.render(StartMenuScreen.java:108)  at com.badlogic.gdx.Game.render(Game.java:46)  at com.badlogic.gdx.backends.android.AndroidGraphics.onDrawFrame(AndroidGraphics.java:474)  at android.opengl.GLSurfaceView$GLThread.guardedRun(GLSurfaceView.java:1531)  at android.opengl.GLSurfaceView$GLThread.run(GLSurfaceView.java:1248)  Caused by: com.badlogic.gdx.utils.GdxRuntimeException: Error reading file: trollWalk1.png (Internal) at com.badlogic.gdx.backends.android.AndroidFileHandle.read(AndroidFileHandle.java:77) at com.badlogic.gdx.files.FileHandle.readBytes(FileHandle.java:222) at com.badlogic.gdx.graphics.Pixmap.(Pixmap.java:145) at com.badlogic.gdx.graphics.TextureData$Factory.loadFromFile(TextureData.java:98)  at com.badlogic.gdx.graphics.Texture.(Texture.java:100)  at com.badlogic.gdx.graphics.Texture.(Texture.java:92)  at com.dotabmot.game.Assets.(Assets.java:112)  at com.dotabmot.game.StartMenuScreen.render(StartMenuScreen.java:108)  at com.badlogic.gdx.Game.render(Game.java:46)  at com.badlogic.gdx.backends.android.AndroidGraphics.onDrawFrame(AndroidGraphics.java:474)  at android.opengl.GLSurfaceView$GLThread.guardedRun(GLSurfaceView.java:1531)  at android.opengl.GLSurfaceView$GLThread.run(GLSurfaceView.java:1248)  Caused by: java.io.FileNotFoundException: trollWalk1.png at android.content.res.AssetManager.openAsset(Native Method) at android.content.res.AssetManager.open(AssetManager.java:324) at android.content.res.AssetManager.open(AssetManager.java:298) at com.badlogic.gdx.backends.android.AndroidFileHandle.read(AndroidFileHandle.java:75) at com.badlogic.gdx.files.FileHandle.readBytes(FileHandle.java:222)  at com.badlogic.gdx.graphics.Pixmap.(Pixmap.java:145)  at com.badlogic.gdx.graphics.TextureData$Factory.loadFromFile(TextureData.java:98)  at com.badlogic.gdx.graphics.Texture.(Texture.java:100)  at com.badlogic.gdx.graphics.Texture.(Texture.java:92)  at com.dotabmot.game.Assets.(Assets.java:112)  at com.dotabmot.game.StartMenuScreen.render(StartMenuScreen.java:108)  at com.badlogic.gdx.Game.render(Game.java:46)  at com.badlogic.gdx.backends.android.AndroidGraphics.onDrawFrame(AndroidGraphics.java:474)  at android.opengl.GLSurfaceView$GLThread.guardedRun(GLSurfaceView.java:1531)  at android.opengl.GLSurfaceView$GLThread.run(GLSurfaceView.java:1248)  07-24 12:12:14.782 9442-9442/? E/AndroidGraphics: waiting for pause synchronization took too long; assuming deadlock and killing

Android Studio shows no errors while compiling, how to solve this error?

Here is some code which is related to the error: Inside Assets Class:

public class Assets {

// The Rock Wall Background
public static Texture textureRockWall = new Texture(Gdx.files.internal("rockWall.jpg"));
public static TextureRegion rockWall = new TextureRegion(textureRockWall, 0, 0, 600, 450);
// The New Game Button
public static Texture textureNewGameButton = new Texture(Gdx.files.internal("newGameButton.png"));
public static TextureRegion newGameButton = new TextureRegion(textureNewGameButton, 0, 0, 139, 351);

Inside the StartMenuScreen Class:

public class StartMenuScreen implements Screen {

public void render(float delta) {

    // Draw Background Rock Wall
    batcher.begin();
    batcher.draw(Assets.rockWall, 0, 0, 160, 90); **// THIS LINE IS WHERE I GET THE ERROR. IF I REMOVE THIS LINE I GET THE SAME ERROR FOR THE NEXT STATIC OBJECT WHICH IS Assets.newGameButtonClicked...**
    //Screen1
    if(screen1) {
        if(!StartMenuScreenInputHandler.newGameButtonClicked) {
            batcher.draw(Assets.newGameButton, 50, 15, 15, 60);
        } else if(StartMenuScreenInputHandler.newGameButtonClicked){
            batcher.draw(Assets.newGameButtonP, 50, 15, 15, 60);
            if(goAhead){
                goAhead = false;
                StartMenuScreenInputHandler.newGameButtonClicked = false;
                buttonCounter = 0;
                screen1 = false;
                screen2 = true;
            }
        }    

}

7
  • So hard to tell without seeing any code... Commented Jul 24, 2016 at 22:42
  • Hi nasch, I added the related code, since it would be too long to put more. Could you take a look at it again? Thanks a lot. Commented Jul 27, 2016 at 12:46
  • Where is StartMenuScreen line 108? Commented Jul 27, 2016 at 13:35
  • This is the StartMenuScreen line 108: "batcher.draw(Assets.rockWall, 0, 0, 160, 90);" Commented Jul 28, 2016 at 14:03
  • OK here's the problem, from your stack trace: Caused by: java.io.FileNotFoundException: trollWalk1.png Commented Jul 28, 2016 at 15:41

1 Answer 1

1

OK here's the problem, from your stack trace:

Caused by: java.io.FileNotFoundException: trollWalk1.png
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.