执行代码时我的Android崩溃了

时间:2016-02-09 17:38:47

标签: java android json intellij-idea

当我使用DesktopLaucher在IntelliJ上运行此LibGdx代码时,它很好。 但当我通过USB将其运行到我的Android时,应用程序崩溃了。

public class GraphicInterface extends ApplicationAdapter {
private Stage Graphs;
    Camera screen = new OrthographicCamera();
    public Skin skin;


    @Override
    public void create () {
        skin = new Skin(Gdx.files.internal("uiskin.json"));
        Graphs = new Stage(new ScreenViewport());

        final TextButton button1 = new TextButton("Click me", skin,"default");
            button1.setWidth(200f);
            button1.setHeight(50f);

        final Dialog texto = new Dialog("Click Message", skin);

        button1.addListener(new ClickListener(){
            @Override
            public void clicked(InputEvent event, float x, float y){
                texto.show(Graphs);
                Timer.schedule(new Timer.Task(){
                    @Override
                            public void run() {
                        texto.hide();
                    }
                },5);
            }
        });
        Graphs.addActor(button1);
        Gdx.input.setInputProcessor(Graphs);

    }

    @Override
    public void render () {
        Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT);
        Graphs.act(Gdx.graphics.getDeltaTime());
        Graphs.draw();
    }
}

我还添加了一个Json文件:

{
    com.badlogic.gdx.graphics.g2d.BitmapFont: {
        default-font: {
            file: Razer.fnt
        }
    },
    com.badlogic.gdx.scenes.scene2d.ui.TextButton$TextButtonStyle: {
        default: {
            down: default-round-down,
            up: default-round,
            font: default-font
        },
    },
    com.badlogic.gdx.scenes.scene2d.ui.Window$WindowStyle: {
        default: {
            titleFont: default-font
        }
    }
}

我从The Libgdx(GitHub'i think)和教程

获取了最后一部分

1 个答案:

答案 0 :(得分:0)

我发现,我从libgdx-master.zip下载了文件uiskin.png uiskin.atlas

https://github.com/libgdx/libgdx/tree/master/tests/gdx-tests-android/assets/data

看起来Android版需要更多组件才能运行该应用程序!

希望这对其他人也有效。 - 为我的新手而战:)