我正在学习集成swarm和libgdx的教程。链接在这里http://swarmconnect.com/admin/docs/libgdx。
我下载了提供http://swarmconnect.com/login?redirect=%2Fimages%2Fdocs%2Fexample_libgdx_swarm_done.zip的源代码。建筑时没有发生任何错误。当我尝试在模拟器中运行Android应用程序时,“不幸的是,XXX已停止”将弹出。而logcat是
06-04 20:58:37.107: I/dalvikvm(739): threadid=3: reacting to signal 3
06-04 20:58:37.237: I/dalvikvm(739): Wrote stack traces to '/data/anr/traces.txt'
06-04 20:58:37.553: D/(739): HostConnection::get() New Host Connection established 0x15c610, tid 739
06-04 20:58:37.637: I/dalvikvm(739): threadid=3: reacting to signal 3
06-04 20:58:37.657: I/dalvikvm(739): Wrote stack traces to '/data/anr/traces.txt'
06-04 20:58:40.808: I/dalvikvm(739): Could not find method com.swarmconnect.Swarm.setActive, referenced from method com.badlogicgames.superjumper.SuperJumperAndroid.onCreate
06-04 20:58:40.817: W/dalvikvm(739): VFY: unable to resolve static method 9558: Lcom/swarmconnect/Swarm;.setActive (Landroid/app/Activity;)V
06-04 20:58:40.817: D/dalvikvm(739): VFY: replacing opcode 0x71 at 0x000c
06-04 20:58:40.817: I/dalvikvm(739): Could not find method com.swarmconnect.Swarm.setInactive, referenced from method com.badlogicgames.superjumper.SuperJumperAndroid.onPause
06-04 20:58:40.817: W/dalvikvm(739): VFY: unable to resolve static method 9559: Lcom/swarmconnect/Swarm;.setInactive (Landroid/app/Activity;)V
06-04 20:58:40.817: D/dalvikvm(739): VFY: replacing opcode 0x71 at 0x0003
06-04 20:58:40.827: I/dalvikvm(739): Could not find method com.swarmconnect.Swarm.setActive, referenced from method com.badlogicgames.superjumper.SuperJumperAndroid.onResume
06-04 20:58:40.827: W/dalvikvm(739): VFY: unable to resolve static method 9558: Lcom/swarmconnect/Swarm;.setActive (Landroid/app/Activity;)V
06-04 20:58:40.827: D/dalvikvm(739): VFY: replacing opcode 0x71 at 0x0003
06-04 20:58:40.847: D/dalvikvm(739): Trying to load lib /data/data/com.badlogicgames.superjumper/lib/libgdx.so 0x412a0128
06-04 20:58:40.847: D/dalvikvm(739): Added shared lib /data/data/com.badlogicgames.superjumper/lib/libgdx.so 0x412a0128
06-04 20:58:40.847: D/dalvikvm(739): No JNI_OnLoad found in /data/data/com.badlogicgames.superjumper/lib/libgdx.so 0x412a0128, skipping init
06-04 20:58:40.927: D/AndroidRuntime(739): Shutting down VM
06-04 20:58:40.927: W/dalvikvm(739): threadid=1: thread exiting with uncaught exception (group=0x409c01f8)
06-04 20:58:40.947: E/AndroidRuntime(739): FATAL EXCEPTION: main
06-04 20:58:40.947: E/AndroidRuntime(739): java.lang.NoClassDefFoundError: com.swarmconnect.Swarm
06-04 20:58:40.947: E/AndroidRuntime(739): at com.badlogicgames.superjumper.SuperJumperAndroid.onCreate(SuperJumperAndroid.java:33)
06-04 20:58:40.947: E/AndroidRuntime(739): at android.app.Activity.performCreate(Activity.java:4465)
06-04 20:58:40.947: E/AndroidRuntime(739): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1049)
06-04 20:58:40.947: E/AndroidRuntime(739): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1920)
06-04 20:58:40.947: E/AndroidRuntime(739): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1981)
06-04 20:58:40.947: E/AndroidRuntime(739): at android.app.ActivityThread.access$600(ActivityThread.java:123)
06-04 20:58:40.947: E/AndroidRuntime(739): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1147)
06-04 20:58:40.947: E/AndroidRuntime(739): at android.os.Handler.dispatchMessage(Handler.java:99)
06-04 20:58:40.947: E/AndroidRuntime(739): at android.os.Looper.loop(Looper.java:137)
06-04 20:58:40.947: E/AndroidRuntime(739): at android.app.ActivityThread.main(ActivityThread.java:4424)
06-04 20:58:40.947: E/AndroidRuntime(739): at java.lang.reflect.Method.invokeNative(Native Method)
06-04 20:58:40.947: E/AndroidRuntime(739): at java.lang.reflect.Method.invoke(Method.java:511)
06-04 20:58:40.947: E/AndroidRuntime(739): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:784)
06-04 20:58:40.947: E/AndroidRuntime(739): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:551)
06-04 20:58:40.947: E/AndroidRuntime(739): at dalvik.system.Nati
veStart.main(Native Method)
06-04 20:58:41.277: I/dalvikvm(739): threadid=3: reacting to signal 3
06-04 20:58:41.308: I/dalvikvm(739): Wrote stack traces to '/data/anr/traces.txt'
06-04 20:58:41.557: I/dalvikvm(739): threadid=3: reacting to signal 3
06-04 20:58:41.577: I/dalvikvm(739): Wrote stack traces to '/data/anr/traces.txt'
它说
06-04 20:58:40.808: I/dalvikvm(739): Could not find method com.swarmconnect.Swarm.setActive, referenced from method com.badlogicgames.superjumper.SuperJumperAndroid.onCreate
06-04 20:58:40.817: W/dalvikvm(739): VFY: unable to resolve static method 9558: Lcom/swarmconnect/Swarm;.setActive (Landroid/app/Activity;)V
06-04 20:58:40.817: D/dalvikvm(739): VFY: replacing opcode 0x71 at 0x000c
06-04 20:58:40.817: I/dalvikvm(739): Could not find method com.swarmconnect.Swarm.setInactive, referenced from method com.badlogicgames.superjumper.SuperJumperAndroid.onPause
06-04 20:58:40.817: W/dalvikvm(739): VFY: unable to resolve static method 9559: Lcom/swarmconnect/Swarm;.setInactive (Landroid/app/Activity;)V
但我将swarm项目添加到superjumper-android项目中。有人遇到过类似的问题吗?
答案 0 :(得分:1)
看起来Swarm.jar没有包含在APK中。
请确保您已从教程中完成了以下步骤:
您可能需要将superjumper-android项目的“Swarm.jar”标记为“已导出”:属性> Java构建路径> “订购和导出”选项卡>确保检查Swarm.jar是否导出。 Android SDK团队不断调整(即打破)包含其他项目和库的Android项目的构建过程。如果您使用的是SDK v22,请参阅:Libraries do not get added to APK anymore after upgrade to ADT 22
最后,如果这些都没有帮助,请检查How can I use external JARs in an Android project?,它有许多不同的答案(对于无法找到jar文件的许多方式)。