gpt4 book ai didi

java.lang.NoClassDefFoundError(libgdx)

转载 作者:塔克拉玛干 更新时间:2023-11-02 08:57:27 28 4
gpt4 key购买 nike

一直在尝试使用 Libgdx 框架,但遇到了一些令人沮丧的问题。我正在学习教程,但无法运行我的项目。我做错了什么?

package com.mygdx.game.android;

import com.badlogic.gdx.ApplicationListener;
import com.badlogic.gdx.Gdx;
import com.badlogic.gdx.graphics.Texture;
import com.badlogic.gdx.graphics.g2d.SpriteBatch;

public class AndroidLauncher implements ApplicationListener {

SpriteBatch batch;
Texture mario;


@Override
public void create() {
batch = new SpriteBatch();

mario = new Texture(Gdx.files.internal("mario.png"));
}

@Override
public void resize(int width, int height) {
// TODO Auto-generated method stub

}

@Override
public void render() {
Gdx.gl.glClearColor(1,1,1,1);


batch.begin();
batch.draw(mario, 50, 50);
batch.end();



}

@Override
public void pause() {
// TODO Auto-generated method stub

}

@Override
public void resume() {
// TODO Auto-generated method stub

}

@Override
public void dispose() {
// TODO Auto-generated method stub

}

}

这是我运行项目时控制台显示的内容:

Exception in thread "main" java.lang.NoClassDefFoundError: com/badlogic/gdx/jnigen/NativeCodeGenerator
at com.badlogic.gdx.utils.GdxBuild.main(GdxBuild.java:34)
Caused by: java.lang.ClassNotFoundException: com.badlogic.gdx.jnigen.NativeCodeGenerator
at java.net.URLClassLoader$1.run(URLClassLoader.java:366)
at java.net.URLClassLoader$1.run(URLClassLoader.java:355)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:354)
at java.lang.ClassLoader.loadClass(ClassLoader.java:425)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:308)
at java.lang.ClassLoader.loadClass(ClassLoader.java:358)
... 1 more

最佳答案

我遇到了同样的问题,但意识到我正在运行 GdxBuild。确保右键单击 DesktopLauncher.java > Run As > Java Application。

关于java.lang.NoClassDefFoundError(libgdx),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25080731/

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com