【发布时间】:2017-02-08 00:11:30
【问题描述】:
我使用 libgdx 制作了一个游戏,它之前在桌面和安卓上运行良好。我不确定是不是因为我开始使用box2d物理引擎和liquidfun粒子,基本上发生的情况是,当我在我的游戏上单击播放时它开始加载,然后加载后它应该进入游戏屏幕,但它崩溃然后说“不幸的是,myGame 已停止”。
错误信息:
E/AndroidRuntime: FATAL EXCEPTION: GLThread 3764
Process: com.nivekbryan.puffypuff, PID: 8416
java.lang.NoClassDefFoundError: Failed resolution of: Lcom/badlogic/gdx/physics/box2d/World;
我关注了这个setup tutorial 关于如何移植liquidfun 库,它从2014 年开始有点旧。 游戏可以作为桌面应用程序运行。
这是我的 build.gradle 文件(依赖项),可能是什么问题?为什么是桌面应用而不是安卓应用?
buildscript {
repositories {
mavenLocal()
mavenCentral()
maven { url "https://oss.sonatype.org/content/repositories/snapshots/" }
jcenter()
}
dependencies {
classpath 'de.richsource.gradle.plugins:gwt-gradle-plugin:0.6'
classpath 'com.android.tools.build:gradle:2.0.0'
classpath 'com.mobidevelop.robovm:robovm-gradle-plugin:2.1.0'
}
}
allprojects {
apply plugin: "eclipse"
apply plugin: "idea"
version = '1.0'
ext {
appName = "Puffy Puff"
gdxVersion = '1.9.3'
roboVMVersion = '2.1.0'
box2DLightsVersion = '1.4'
ashleyVersion = '1.7.0'
aiVersion = '1.8.0'
admobVersion = '8.3.0'
}
repositories {
mavenLocal()
mavenCentral()
maven { url "https://oss.sonatype.org/content/repositories/snapshots/" }
maven { url "https://oss.sonatype.org/content/repositories/releases/" }
}
}
project(":desktop") {
apply plugin: "java"
dependencies {
compile project(":core")
compile "com.badlogicgames.gdx:gdx-backend-lwjgl:$gdxVersion"
compile "com.badlogicgames.gdx:gdx-platform:$gdxVersion:natives-desktop"
compile "com.badlogicgames.gdx:gdx-freetype-platform:$gdxVersion:natives-desktop"
compile fileTree(dir: 'libs', include: '*.jar')
}
}
project(":android") {
apply plugin: "android"
configurations { natives }
dependencies {
compile project(":core")
compile "com.badlogicgames.gdx:gdx-backend-android:$gdxVersion"
natives "com.badlogicgames.gdx:gdx-platform:$gdxVersion:natives-armeabi"
natives "com.badlogicgames.gdx:gdx-platform:$gdxVersion:natives-armeabi-v7a"
natives "com.badlogicgames.gdx:gdx-platform:$gdxVersion:natives-arm64-v8a"
natives "com.badlogicgames.gdx:gdx-platform:$gdxVersion:natives-x86"
natives "com.badlogicgames.gdx:gdx-platform:$gdxVersion:natives-x86_64"
compile "com.badlogicgames.gdx:gdx-freetype:$gdxVersion"
natives "com.badlogicgames.gdx:gdx-freetype-platform:$gdxVersion:natives-armeabi"
natives "com.badlogicgames.gdx:gdx-freetype-platform:$gdxVersion:natives-armeabi-v7a"
natives "com.badlogicgames.gdx:gdx-freetype-platform:$gdxVersion:natives-arm64-v8a"
natives "com.badlogicgames.gdx:gdx-freetype-platform:$gdxVersion:natives-x86"
natives "com.badlogicgames.gdx:gdx-freetype-platform:$gdxVersion:natives-x86_64"
compile "com.google.android.gms:play-services-ads:8.3.0"
compile fileTree(dir: 'libs', include: '*.so')
}
}
project(":ios") {
apply plugin: "java"
apply plugin: "robovm"
dependencies {
compile project(":core")
compile "com.mobidevelop.robovm:robovm-rt:$roboVMVersion"
compile "com.mobidevelop.robovm:robovm-cocoatouch:$roboVMVersion"
compile "com.badlogicgames.gdx:gdx-backend-robovm:$gdxVersion"
compile "com.badlogicgames.gdx:gdx-platform:$gdxVersion:natives-ios"
compile "com.badlogicgames.gdx:gdx-freetype-platform:$gdxVersion:natives-ios"
}
}
project(":html") {
apply plugin: "gwt"
apply plugin: "war"
dependencies {
compile project(":core")
compile "com.badlogicgames.gdx:gdx-backend-gwt:$gdxVersion"
compile "com.badlogicgames.gdx:gdx:$gdxVersion:sources"
compile "com.badlogicgames.gdx:gdx-backend-gwt:$gdxVersion:sources"
}
}
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')
}
}
tasks.eclipse.doLast {
delete ".project"
}
更新:
我找到了这个解决方案link 所以我所做的是将 gdx-liquidfun.jar 复制到 Android -> libs 然后右键单击并添加为库,但我仍然得到错误。请帮助,在此先感谢(我正在使用 Intellij 社区版)
【问题讨论】:
-
你的gradle可能有问题,请将它们添加到你的问题中。
-
下面的答案有什么问题?您说类解析,但某些方法不起作用,因此您似乎需要阅读 API 文档以找到正确的参数
-
@cricket_007 - 我使用 LiquidFun 处理粒子,LiquidFun 基于 Box2d 所以当你使用 LiquidFun 时,world.step 将需要 4 个参数。但是如果我使用普通的Box2d那么只需要3个参数,下面的答案基本上会让我只使用box2d,但我需要LiquidFun来处理粒子。
-
这些 eclipse 指令相当于 Gradle 中的
compile fileTree(dir: 'libs', include: '*.jar')并将 jar 文件放入该 libs 文件夹。 -
@ cricket_007 - 天哪,成功了!所以我将gdx-liquidfun.jar复制到android - > libs,然后在我添加的android依赖项下的主build.gradle上 - 编译fileTree(dir:'libs',包括:'gdx-liquidfun.jar')。谢谢,赏金?
标签: java android libgdx box2d liquidfun