Ошибка JNI - libGDX ApplicationListener не найден - PullRequest
2 голосов
/ 08 марта 2020

Итак, я только что экспортировал свой проект в виде JAR-файла. Я делаю только настольное приложение. При попытке запустить программу я получаю
"Произошла ошибка JNI .." Больше ничего нет. Однако в командной строке обнаруживается, что

"Исключение в потоке" main "java .lang.NoClassDefFoundError: com / badlogic / gdx / ApplicationListener"

Так что libGDX ApplicationListener может не может быть найден? Он отлично работает при компиляции / запуске в Eclipse.

Я использую:
Windows 7 Ultimate
Eclipse Oxygen.3a
Gradle 4.4.1
java JRE версии 1.8.0_241
java JDK версии 1.8.0_241

Переменные среды:
PATH_HOME:"C: \ Program Files \ Java \ jdk1.8.0_241 "
var: " C: \ Program Files \ Java \ jdk1.8.0_241 \ bin "
Путь:"C: \ Program Files (x86) \ Common Files \ Oracle \ Java \ javapath; C: \ ProgramData \ Oracle \ Java \ javapath; C: \ Windows \ system32; C: \ Windows; C: \ Windows \ System32 \ Wbem; C: \ Windows \ System32 \ WindowsPowerShell \ v1.0 \; C: \ Gradle \ gradle-4.4.1 \ bin "

Основной класс

public class DesktopLauncher
{
    public static boolean rebuildAtlas = true;
    public static boolean drawDebugOutline = true;

    public static void main (String[] arg)
    {
        // Build Texture Atlases
        if (rebuildAtlas) {
            Settings settings = new Settings();
            settings.maxWidth = 1024;
            settings.maxHeight = 1024;
            settings.combineSubdirectories = true;

            // Pack images in "textures" folder
            TexturePacker.process("assets/textures", "assets/atlas", "textures.atlas");

        }   

        LwjglApplicationConfiguration cfg = new LwjglApplicationConfiguration();

        cfg.title = "TI Helper";
        cfg.useGL30 = false;
        cfg.width = Cn.RESOLUTION_WIDTH;
        cfg.height = Cn.RESOLUTION_HEIGHT;
        cfg.fullscreen = true;

        new LwjglApplication(new ti_app(), cfg);
    }
}

Рабочий стол build.gradle

apply plugin: "java"

sourceCompatibility = 1.8
sourceSets.main.java.srcDirs = [ "src/" ]
sourceSets.main.resources.srcDirs = ["../core/assets"]

project.ext.mainClassName = "com.lf.desktop.DesktopLauncher"
project.ext.assetsDir = new File("../core/assets")

task run(dependsOn: classes, type: JavaExec) {
    main = project.mainClassName
    classpath = sourceSets.main.runtimeClasspath
    standardInput = System.in
    workingDir = project.assetsDir
    ignoreExitValue = true
}

task debug(dependsOn: classes, type: JavaExec) {
    main = project.mainClassName
    classpath = sourceSets.main.runtimeClasspath
    standardInput = System.in
    workingDir = project.assetsDir
    ignoreExitValue = true
    debug = true
}

task dist(type: Jar) {
    manifest {
        attributes 'Main-Class': project.mainClassName
    }
    dependsOn configurations.runtimeClasspath
    from {
        configurations.runtimeClasspath.collect { it.isDirectory() ? it : zipTree(it) }
    }
    with jar
}

dist.dependsOn classes

Ядро build.gradle

apply plugin: "java"

sourceCompatibility = 1.8
[compileJava, compileTestJava]*.options*.encoding = 'UTF-8'

sourceSets.main.java.srcDirs = [ "src/" ]

Рабочая область build.gradle

buildscript {

    repositories {
        mavenLocal()
        mavenCentral()
        maven { url "https://plugins.gradle.org/m2/" }
        maven { url "https://oss.sonatype.org/content/repositories/snapshots/" }
        jcenter()
        google()
    }
    dependencies {

    }
}

allprojects {
    apply plugin: "eclipse"
    version = '1.0'
    ext {
        appName = "TIHelper"
        gdxVersion = '1.9.10'
        roboVMVersion = '2.3.8'
        box2DLightsVersion = '1.4'
        ashleyVersion = '1.7.0'
        aiVersion = '1.8.0'
    }

    repositories {
        mavenLocal()
        mavenCentral()
        jcenter()
        google()
        maven { url "https://oss.sonatype.org/content/repositories/snapshots/" }
        maven { url "https://oss.sonatype.org/content/repositories/releases/" }
    }
}

project(":desktop") {
    apply plugin: "java-library"

    dependencies {
        implementation project(":core")
        api "com.badlogicgames.gdx:gdx-backend-lwjgl:$gdxVersion"
        api "com.badlogicgames.gdx:gdx-platform:$gdxVersion:natives-desktop"
        api "com.badlogicgames.gdx:gdx-box2d-platform:$gdxVersion:natives-desktop"
        api "com.badlogicgames.gdx:gdx-tools:$gdxVersion"
        api "com.badlogicgames.gdx:gdx-freetype-platform:$gdxVersion:natives-desktop"
        api "com.badlogicgames.gdx:gdx-bullet-platform:$gdxVersion:natives-desktop"  
    }
}

project(":core") {
    apply plugin: "java-library"

    dependencies {
        api "com.badlogicgames.gdx:gdx:$gdxVersion"
        api "com.badlogicgames.gdx:gdx-box2d:$gdxVersion"
        api "com.badlogicgames.gdx:gdx-freetype:$gdxVersion"
        api "com.badlogicgames.gdx:gdx-bullet:$gdxVersion"
        api "com.badlogicgames.box2dlights:box2dlights:$box2DLightsVersion"
        api "com.badlogicgames.gdx:gdx-ai:$aiVersion"
        api "net.dermetfan.libgdx-utils:libgdx-utils:0.13.4"
        api "net.dermetfan.libgdx-utils:libgdx-utils-box2d:0.13.4"
        api "com.badlogicgames.ashley:ashley:$ashleyVersion"
    }
}

Единственные тревожные рассказы также предполагают, что я мог пропустить какой-то собственный JAR-файл (gdx-native.jar или что-то в этом роде) среди м у внешние зависимости

Но те темы, где годы, так что, думаю, у меня это есть, просто называются "gdx-platform-1.9.10-natives-desktop.jar" в наше время. Или проблема связана с тем, что в проекте указано Собственное расположение библиотеки: (нет) ? Я немного потерян здесь, я должен сказать. Банки libGDX не экспортируются?

...