我正在使用KryoNet
和Javax Swing
我在Android设备上运行我的应用时出现问题。首先我在NoClassDefFoundError
上获得com.esotericsoftware.krynet.Client
。我发现这很奇怪,因为它在核心项目中被引用,并且应该像其他所有Java jar一样,可以在Android项目中访问。
所以我也将kryonet
添加到了android libs
文件夹中,并摆脱了这个错误。但随后为Javax swing
弹出了同样的错误。我相信这些类驻留在java rt.jar
中,所以我做了同样的事情,但这给我一个GC overhead limit exceeded
错误。
我似乎无法让我的客户端运行,下面是logcat转储:
09-22 19:33:17.054: W/dalvikvm(18600): VFY: unable to resolve static method 13924: Ljavax/swing/JOptionPane;.showInputDialog (Ljava/awt/Component;Ljava/lang/Object;Ljava/lang/String;ILjavax/swing/Icon;[Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object;
09-22 19:33:17.054: D/dalvikvm(18600): VFY: replacing opcode 0x77 at 0x0029
09-22 19:33:17.054: W/dalvikvm(18600): Unable to resolve superclass of Lmg/realmofradiance/client/ChatClient$ChatFrame; (1425)
09-22 19:33:17.054: W/dalvikvm(18600): Link of class 'Lmg/realmofradiance/client/ChatClient$ChatFrame;' failed
09-22 19:33:17.054: D/dalvikvm(18600): DexOpt: unable to opt direct call 0x368b at 0x67 in Lmg/realmofradiance/client/ChatClient;.<init>
09-22 19:33:17.095: I/dalvikvm(18600): Could not find method java.awt.EventQueue.invokeLater, referenced from method mg.realmofradiance.client.ChatClient$1.disconnected
09-22 19:33:17.095: W/dalvikvm(18600): VFY: unable to resolve static method 13056: Ljava/awt/EventQueue;.invokeLater (Ljava/lang/Runnable;)V
09-22 19:33:17.095: D/dalvikvm(18600): VFY: replacing opcode 0x71 at 0x0005
09-22 19:33:17.095: W/dalvikvm(18600): Unable to resolve superclass of Lmg/realmofradiance/client/ChatClient$ChatFrame; (1425)
09-22 19:33:17.095: W/dalvikvm(18600): Link of class 'Lmg/realmofradiance/client/ChatClient$ChatFrame;' failed
09-22 19:33:17.105: W/dalvikvm(18600): Unable to resolve superclass of Lmg/realmofradiance/client/ChatClient$ChatFrame; (1425)
09-22 19:33:17.105: W/dalvikvm(18600): Link of class 'Lmg/realmofradiance/client/ChatClient$ChatFrame;' failed
09-22 19:33:17.105: I/dalvikvm(18600): Could not find method mg.realmofradiance.client.ChatClient$ChatFrame.setNames, referenced from method mg.realmofradiance.client.ChatClient$1.received
09-22 19:33:17.105: W/dalvikvm(18600): VFY: unable to resolve virtual method 13972: Lmg/realmofradiance/client/ChatClient$ChatFrame;.setNames ([Ljava/lang/String;)V
09-22 19:33:17.105: D/dalvikvm(18600): VFY: replacing opcode 0x6e at 0x000d
09-22 19:33:17.105: W/dalvikvm(18600): Unable to resolve superclass of Lmg/realmofradiance/client/ChatClient$ChatFrame; (1425)
09-22 19:33:17.105: W/dalvikvm(18600): Link of class 'Lmg/realmofradiance/client/ChatClient$ChatFrame;' failed
09-22 19:33:17.105: W/dalvikvm(18600): Unable to resolve superclass of Lmg/realmofradiance/client/ChatClient$ChatFrame; (1425)
09-22 19:33:17.105: W/dalvikvm(18600): Link of class 'Lmg/realmofradiance/client/ChatClient$ChatFrame;' failed
09-22 19:33:17.105: I/dalvikvm(18600): Could not find method mg.realmofradiance.client.ChatClient$ChatFrame.addMessage, referenced from method mg.realmofradiance.client.ChatClient$1.received
09-22 19:33:17.105: W/dalvikvm(18600): VFY: unable to resolve virtual method 13964: Lmg/realmofradiance/client/ChatClient$ChatFrame;.addMessage (Ljava/lang/String;)V
09-22 19:33:17.105: D/dalvikvm(18600): VFY: replacing opcode 0x6e at 0x001e
09-22 19:33:17.105: W/dalvikvm(18600): threadid=11: thread exiting with uncaught exception (group=0x41855da0)
09-22 19:33:17.105: E/AndroidRuntime(18600): FATAL EXCEPTION: GLThread 1651
09-22 19:33:17.105: E/AndroidRuntime(18600): Process: mg.realmofradiance.client.android, PID: 18600
09-22 19:33:17.105: E/AndroidRuntime(18600): java.lang.NoClassDefFoundError: javax.swing.JOptionPane
09-22 19:33:17.105: E/AndroidRuntime(18600): at mg.realmofradiance.client.ChatClient.<init>(ChatClient.java:84)
09-22 19:33:17.105: E/AndroidRuntime(18600): at mg.realmofradiance.client.RealmOfRadianceClient.create(RealmOfRadianceClient.java:19)
09-22 19:33:17.105: E/AndroidRuntime(18600): at com.badlogic.gdx.backends.android.AndroidGraphics.onSurfaceChanged(AndroidGraphics.java:236)
09-22 19:33:17.105: E/AndroidRuntime(18600): at android.opengl.GLSurfaceView$GLThread.guardedRun(GLSurfaceView.java:1520)
09-22 19:33:17.105: E/AndroidRuntime(18600): at android.opengl.GLSurfaceView$GLThread.run(GLSurfaceView.java:1248)
它停在需要Swing的第一行。在我的服务器应用程序上,Swing工作正常,只是没有客户端那样的摇摆gui。 Afaik swing应与android兼容。下面是我的代码断开的行,类ChatClient上的第84行。
String input = (String)JOptionPane.showInputDialog(null, "IP:",
"Connect to lobby", JOptionPane.QUESTION_MESSAGE,
null, null, "127.0.0.1");
在服务器端,这是工作,我使用一个简单的摆动Jframe(但是我的Android设备上没有显示。所以也许android与swing不兼容,我仍然确定我读它应该变换swing在Android上将窗格简化为UI。
答案 0 :(得分:2)
Android不支持Swing图形库,因为它拥有它。使用AlertDialog。
答案 1 :(得分:0)
Android手机没有javax.swing
套餐。您将不得不为您的应用程序计算其他内容。