Stubborn libgdx problems!

Started by
9 comments, last by xxSavagexx 9 years, 10 months ago

Hello! A few weeks ago I was working on Android game in eclipse (without ADT or any additional tools) when I found out my app was comepletely useless without SDK.
Then I bought got a book from a library from Andreas Oelkhe about java android programming and started playing around with LibGdx. Well, playing around isn't really what I'm trying to say as I'm still trying to find out how to run the damn app when my HTC Wildfire S is connected to my PC directly.

First problem I had (when running desktop version) was that the app was constantly throwing an error because it couldn't fin the badlogic.jpg which was there, but I somehow fixed it (it was a directory thing, can't really remember everything).

Then, I tried to start the app while my phone was plugged in with debugging enabled and it DOES start (the screen flips to landscape position) but then it creashes right away!
I thought it was the picture problem, so I put it in a comment section temporarily, but it still happens.
The screen flips and then, MyDemo.java (or something) has stopped.
I was so pissed, and I still can't find the right answer. I came here to you guys hoping some of you had experienced the same problem before.

Oh, my Android version is 4.4.2, it is a bit unstable, but all the apps seem to be working quite well, some system processes sometimes crash, but that's it. Thanks in advance!

Advertisement

Okay, I got to the source of the problem.
Let me first coppy the code and highlight all the spots causing it

package com.packtub.libgdx.demo;

import com.badlogic.gdx.ApplicationAdapter;
import com.badlogic.gdx.Gdx;
import com.badlogic.gdx.graphics.GL20;
import com.badlogic.gdx.graphics.Texture;
import com.badlogic.gdx.graphics.g2d.SpriteBatch;

public class MyDemo extends ApplicationAdapter {
    SpriteBatch batch;
    Texture img;<<<<<<<<<<<<<<<<<<
    
    @Override
    public void create () {
        batch = new SpriteBatch();
        img = new Texture("assets/badlogic.jpg");<<<<<<<<<<<<<<<<<<<
    }

    @Override
    public void render () {
        Gdx.gl.glClearColor(1, 0, 0, 1);
        Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT);
        batch.begin();
        batch.draw(img, 0, 0);<<<<<<<<<<<<<<<<<<<<<
        batch.end();
    }
}

When I try to run the app with these three lines put under comment section, the app starts with red background, when I put them back together, the app crashes. Under error section, it says something like badlogic.jpg cant be found but I got it in assets folder in demo, android and desktop version!

Thanks!

"assets/badlogic.jpg" should probably be "assets//badlogic.jpg".

You need to escape the '/' character in the string.

Hello to all my stalkers.

Isn't the escape character '\' blink.png ??

That would apply to a win32 path like "assets\\badlogic.jpg"

I'd say it's more like a working directory problem.

Oops, yes. Disregard my post.

Hello to all my stalkers.

Wait, so, what's seems to be the problem then?

bump

My guess (without the exact error message) is that the file cannot be found for some reason. Maybe it isn't in exactly the right place. Maybe the file is corrupt. Maybe thre is some other problem. Give the exact error message.

I'll send you, I gotta get some stuff done on the faculty and I'll get back to you as soon as I get a chance.

Hello, sorry for not getting back sooner!

OK, I updated everything on my eclipse, I downloaded newest libgdx, created new project, didn't mess around with the code and I tried starting the application (Desktop version)
On my guess, the same error is stopping dektop and android version from starting.
So...Here's the error.


Exception in thread "LWJGL Application" com.badlogic.gdx.utils.GdxRuntimeException: Couldn't load file: badlogic.jpg
	at com.badlogic.gdx.graphics.Pixmap.<init>(Pixmap.java:140)
	at com.badlogic.gdx.graphics.glutils.FileTextureData.prepare(FileTextureData.java:64)
	at com.badlogic.gdx.graphics.Texture.load(Texture.java:130)
	at com.badlogic.gdx.graphics.Texture.<init>(Texture.java:121)
	at com.badlogic.gdx.graphics.Texture.<init>(Texture.java:100)
	at com.badlogic.gdx.graphics.Texture.<init>(Texture.java:92)
	at com.badlogic.gdx.graphics.Texture.<init>(Texture.java:88)
	at com.imstudios.demo.Main.create(Main.java:16)
	at com.badlogic.gdx.backends.lwjgl.LwjglApplication.mainLoop(LwjglApplication.java:136)
	at com.badlogic.gdx.backends.lwjgl.LwjglApplication$1.run(LwjglApplication.java:114)
Caused by: com.badlogic.gdx.utils.GdxRuntimeException: File not found: badlogic.jpg (Internal)
	at com.badlogic.gdx.files.FileHandle.read(FileHandle.java:136)
	at com.badlogic.gdx.files.FileHandle.readBytes(FileHandle.java:220)
	at com.badlogic.gdx.graphics.Pixmap.<init>(Pixmap.java:137)
	... 9 more

This topic is closed to new replies.

Advertisement