java.lang.NoClassDefFoundError (libgdx)

java.lang.NoClassDefFoundError (libgdx)(java.lang.NoClassDefFoundError (libgdx))
本文介绍了java.lang.NoClassDefFoundError (libgdx)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

问题描述

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

Been trying to work with the Libgdx framework and have been experiencing some frustrating issues.. I'm following a tutorial and I'm unable to run my project. What am I doing wrong?

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

    }

}

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

Here's what the console displays when I run the project:

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.

I had the same problem, but realised that I was running GdxBuild instead. Ensure that you right click on DesktopLauncher.java > Run As > Java Application.

这篇关于java.lang.NoClassDefFoundError (libgdx)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

本站部分内容来源互联网,如果有图片或者内容侵犯了您的权益,请联系我们,我们会在确认后第一时间进行删除!

相关文档推荐

Show padding zeros using DecimalFormat(使用 DecimalFormat 显示填充零)
Java decimal formatting using String.format?(使用 String.format 的 Java 十进制格式?)
Sprintf equivalent in Java(Java 中的 Sprintf 等价物)
StAX XML formatting in Java(Java 中的 StAX XML 格式)
Java - format double value as dollar amount(Java - 将双值格式化为美元金额)
Java printf using variable field size?(Java printf使用可变字段大小?)