【问题标题】:LibGDX ClassNotFound on AndroidAndroid 上的 LibGDX ClassNotFound
【发布时间】:2016-08-24 00:07:14
【问题描述】:

我在我的游戏中使用 libGDX,它与另一个项目共享一些代码。我把这段代码放在了一个我在根 build.gradle 中添加的 .jar 库中。

在桌面上一切正常,但是当我在 Android 上启动游戏时,它会因 ClassNotFound 异常而崩溃。它找不到我图书馆的类。

谁能帮帮我?我不知道是什么导致了这个问题。

编辑:对 build.gradle 的更改:

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


    dependencies {
        compile "com.badlogicgames.gdx:gdx:$gdxVersion"
        compile "com.badlogicgames.gdx:gdx-freetype:$gdxVersion"
        compile fileTree(dir: '../libs', include: '*.jar')
    }
}

【问题讨论】:

  • 请显示您对根build.gradle所做的更改。

标签: java android intellij-idea gradle libgdx


【解决方案1】:

您需要直接在 android 模块中添加相同的 fileTree 依赖项,因为 Android Gradle 插件目前无法处理传递的平面文件依赖项。

project(":core") {
   ...
   compile fileTree(dir: '../libs', include: '*.jar')
   ...
}

// And also

project(":android") {
   ...
   compile fileTree(dir: '../libs', include: '*.jar')
   ...
}

Source.

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2011-12-07
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2016-07-22
    • 2015-01-14
    • 2014-06-04
    相关资源
    最近更新 更多