0
votes

I'm using AIDE on my phone to write this program using the libgdx engine. When I run the program it crashes almost instantly. I haven't had a chance to do much but I've narrowed the problem down to trying to load my own pictures. When I delete/disable the code "Texture(Gdx.files.internal("button_center.png"));" the program is able to run. The other image was preloaded on starting the project and doesn't present any issue. I've tried moving my image to the same folder to the image that works and refreshed the build, but the app still crashes.

Here's the code:

package pavlov.murderdoggyalpha;

import com.badlogic.gdx.*;
import com.badlogic.gdx.graphics.*;
import com.badlogic.gdx.graphics.g2d.*;
import pavlov.murderdoggyalpha.*;



public class MyGdxGame implements ApplicationListener
{
    Texture texture;
    Texture butDownLeft;
    Texture butLeft;
    Texture butUpLeft;
    Texture butDown;
    Texture butCenter;
    Texture butUp;
    Texture butDownRight;
    Texture butRight;
    Texture butUpRight;
    SpriteBatch batch;
    int touchX;
    int touchY;


    @Override
    public void create()
    {
        texture = new Texture(Gdx.files.internal("android.jpg"));
        butCenter = new Texture(Gdx.files.internal("button_center.png"));
        batch = new SpriteBatch();
    }

    @Override
    public void render()
    {        
        Gdx.gl.glClearColor(1, 1, 1, 1);
        Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT);
        batch.begin();

        batch.draw(texture, touchX, touchY, 
                   Gdx.graphics.getWidth(), Gdx.graphics.getHeight());
            if (Gdx.input.justTouched());
            {
                touchX = Gdx.input.getX();
                touchY = Gdx.input.getY();
            }
        batch.end();

    }

    @Override
    public void dispose()
    {
    }

    @Override
    public void resize(int width, int height)
    {
    }

    @Override
    public void pause()
    {
    }

    @Override
    public void resume()
    {
    }

}

I believe this is the error log. I apologise in advance, I'm new at this.

This stood out to me:

Caused by: java.io.IOException: couldn't load pixmap 8bit only.

Here's the rest:.

10-23 19:48:59.061 3786 4066 E AndroidRuntime FATAL EXCEPTION: GLThread 30571 10-23 19:48:59.061 3786 4066 E AndroidRuntime Process: pavlov.murderdoggyalpha, PID: 3786 10-23 19:48:59.061 3786 4066 E AndroidRuntime com.badlogic.gdx.utils.GdxRuntimeException: Couldn't load file: button_center.png 10-23 19:48:59.061 3786 4066 E AndroidRuntime at com.badlogic.gdx.graphics.Pixmap.(Pixmap.java:140) 10-23 19:48:59.061 3786 4066 E AndroidRuntime at com.badlogic.gdx.graphics.glutils.FileTextureData.prepare(FileTextureData.java:64) 10-23 19:48:59.061 3786 4066 E AndroidRuntime at com.badlogic.gdx.graphics.Texture.load(Texture.java:130) 10-23 19:48:59.061 3786 4066 E AndroidRuntime at com.badlogic.gdx.graphics.Texture.(Texture.java:121) 10-23 19:48:59.061 3786 4066 E AndroidRuntime at com.badlogic.gdx.graphics.Texture.(Texture.java:100) 10-23 19:48:59.061 3786 4066 E AndroidRuntime at com.badlogic.gdx.graphics.Texture.(Texture.java:92) 10-23 19:48:59.061 3786 4066 E AndroidRuntime at pavlov.murderdoggyalpha.MyGdxGame$0$debug.create(MyGdxGame.java:35) 10-23 19:48:59.061 3786 4066 E AndroidRuntime at pavlov.murderdoggyalpha.MyGdxGame.create(MyGdxGame.java) 10-23 19:48:59.061 3786 4066 E AndroidRuntime at com.badlogic.gdx.backends.android.AndroidGraphics.onSurfaceChanged(AndroidGraphics.java:236) 10-23 19:48:59.061 3786 4066 E AndroidRuntime at android.opengl.GLSurfaceView$GLThread.guardedRun(GLSurfaceView.java:1519) 10-23 19:48:59.061 3786 4066 E AndroidRuntime at android.opengl.GLSurfaceView$GLThread.run(GLSurfaceView.java:1240) 10-23 19:48:59.061 3786 4066 E AndroidRuntime Caused by: java.io.IOException: couldn't load pixmap 8bit only 10-23 19:48:59.061 3786 4066 E AndroidRuntime at com.badlogic.gdx.graphics.g2d.Gdx2DPixmap.(Gdx2DPixmap.java:57) 10-23 19:48:59.061 3786 4066 E AndroidRuntime at com.badlogic.gdx.graphics.Pixmap.(Pixmap.java:138) 10-23 19:48:59.061 3786 4066 E AndroidRuntime ... 10 more 10-23 19:48:59.061 3786 4066 E AndroidRuntime FATAL EXCEPTION: GLThread 30571 10-23 19:48:59.061 3786 4066 E AndroidRuntime Process: pavlov.murderdoggyalpha, PID: 3786 10-23 19:48:59.061 3786 4066 E AndroidRuntime com.badlogic.gdx.utils.GdxRuntimeException: Couldn't load file: button_center.png 10-23 19:48:59.061 3786 4066 E AndroidRuntime at com.badlogic.gdx.graphics.Pixmap.(Pixmap.java:140) 10-23 19:48:59.061 3786 4066 E AndroidRuntime at com.badlogic.gdx.graphics.glutils.FileTextureData.prepare(FileTextureData.java:64) 10-23 19:48:59.061 3786 4066 E AndroidRuntime at com.badlogic.gdx.graphics.Texture.load(Texture.java:130) 10-23 19:48:59.061 3786 4066 E AndroidRuntime at com.badlogic.gdx.graphics.Texture.(Texture.java:121) 10-23 19:48:59.061 3786 4066 E AndroidRuntime at com.badlogic.gdx.graphics.Texture.(Texture.java:100) 10-23 19:48:59.061 3786 4066 E AndroidRuntime at com.badlogic.gdx.graphics.Texture.(Texture.java:92) 10-23 19:48:59.061 3786 4066 E AndroidRuntime at pavlov.murderdoggyalpha.MyGdxGame$0$debug.create(MyGdxGame.java:35) 10-23 19:48:59.061 3786 4066 E AndroidRuntime at pavlov.murderdoggyalpha.MyGdxGame.create(MyGdxGame.java) 10-23 19:48:59.061 3786 4066 E AndroidRuntime at com.badlogic.gdx.backends.android.AndroidGraphics.onSurfaceChanged(AndroidGraphics.java:236) 10-23 19:48:59.061 3786 4066 E AndroidRuntime at android.opengl.GLSurfaceView$GLThread.guardedRun(GLSurfaceView.java:1519) 10-23 19:48:59.061 3786 4066 E AndroidRuntime at android.opengl.GLSurfaceView$GLThread.run(GLSurfaceView.java:1240) 10-23 19:48:59.061 3786 4066 E AndroidRuntime Caused by: java.io.IOException: couldn't load pixmap 8bit only 10-23 19:48:59.061 3786 4066 E AndroidRuntime at com.badlogic.gdx.graphics.g2d.Gdx2DPixmap.(Gdx2DPixmap.java:57) 10-23 19:48:59.061 3786 4066 E AndroidRuntime at com.badlogic.gdx.graphics.Pixmap.(Pixmap.java:138) 10-23 19:48:59.061 3786 4066 E AndroidRuntime ... 10 more 10-2

1
Do you have an error log?Lucas B
I just added itJake
Murder doggy alpha? Really? Anyway, libgdx is having trouble loading your Button_center.png make sure your filename is correct and you have the correct file extensionLucas B
Its an inside joke. Filename and extension is correct.Jake
There has to be something wrong with the file path then. Either filename, extension, or path.Lucas B

1 Answers

0
votes

After doing some digging by googling "Caused by: java.io.IOException: couldn't load pixmap 8bit only" I found that for some reason it has trouble loading 16bit png images. I didn't know how to change it into an 8bit image so I went to lunapics and swapped the file extension to a gif. The app runs fine now.