我错过了一些东西,但我不知道是什么。 使用AVM我可以通过JSCH连接到服务器并执行命令,但当我将.apk移动到我的手机时,它会崩溃。
在我的手机上,如果我写错了IP地址,应用程序会正确抛出错误("无法解析主机......"),但是当IP地址良好时,应用程序崩溃。
因为它适用于AVM,我认为代码很好。但我不知道会发生什么。任何线索?
问候。
编辑:这是来自设备的一些logcat信息:
01-10 17:57:25.922: D/dalvikvm(22282): create interp thread : stack size=32KB
01-10 17:57:25.922: D/dalvikvm(22282): create new thread
01-10 17:57:25.923: D/dalvikvm(22282): new thread created
01-10 17:57:25.923: D/dalvikvm(22282): update thread list
01-10 17:57:25.924: D/dalvikvm(22282): threadid=17: interp stack at 0x60824000
01-10 17:57:25.924: D/dalvikvm(22282): threadid=17: created from interp
01-10 17:57:25.924: D/dalvikvm(22282): start new thread
01-10 17:57:25.924: D/dalvikvm(22282): threadid=17: notify debugger
01-10 17:57:25.924: D/dalvikvm(22282): threadid=17 (Opening Socket 192.168.1.38): calling run()
01-10 17:57:25.927: I/System.out(22282): [CDS]connect[/192.168.1.38:22] tm:90
01-10 17:57:25.928: D/Posix(22282): [Posix_connect Debug]Process com.castizer.castizerapp :22
01-10 17:57:25.948: D/dalvikvm(22282): threadid=17: exiting
01-10 17:57:25.948: D/dalvikvm(22282): threadid=17: bye!
01-10 17:57:25.949: I/System.out(22282): [CDS]rx timeout:60000
01-10 17:57:25.954: I/System.out(22282): [CDS]close[34116]
01-10 17:57:25.955: I/System.out(22282): close [socket][/0.0.0.0:34116]
01-10 17:57:25.955: D/AndroidRuntime(22282): Shutting down VM
01-10 17:57:25.955: W/dalvikvm(22282): threadid=1: thread exiting with uncaught exception (group=0x41f8a9a8)
01-10 17:57:25.966: E/AndroidRuntime(22282): FATAL EXCEPTION: main
01-10 17:57:25.966: E/AndroidRuntime(22282): java.lang.IllegalStateException: Could not execute method of the activity
01-10 17:57:25.966: E/AndroidRuntime(22282): at android.view.View$1.onClick(View.java:3604)
01-10 17:57:25.966: E/AndroidRuntime(22282): at android.view.View.performClick(View.java:4209)
01-10 17:57:25.966: E/AndroidRuntime(22282): at android.widget.CompoundButton.performClick(CompoundButton.java:100)
01-10 17:57:25.966: E/AndroidRuntime(22282): at android.view.View$PerformClick.run(View.java:17431)
01-10 17:57:25.966: E/AndroidRuntime(22282): at android.os.Handler.handleCallback(Handler.java:725)
01-10 17:57:25.966: E/AndroidRuntime(22282): at android.os.Handler.dispatchMessage(Handler.java:92)
01-10 17:57:25.966: E/AndroidRuntime(22282): at android.os.Looper.loop(Looper.java:153)
01-10 17:57:25.966: E/AndroidRuntime(22282): at android.app.ActivityThread.main(ActivityThread.java:5297)
01-10 17:57:25.966: E/AndroidRuntime(22282): at java.lang.reflect.Method.invokeNative(Native Method)
01-10 17:57:25.966: E/AndroidRuntime(22282): at java.lang.reflect.Method.invoke(Method.java:511)
01-10 17:57:25.966: E/AndroidRuntime(22282): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:833)
01-10 17:57:25.966: E/AndroidRuntime(22282): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:600)
01-10 17:57:25.966: E/AndroidRuntime(22282): at dalvik.system.NativeStart.main(Native Method)
01-10 17:57:25.966: E/AndroidRuntime(22282): Caused by: java.lang.reflect.InvocationTargetException
01-10 17:57:25.966: E/AndroidRuntime(22282): at java.lang.reflect.Method.invokeNative(Native Method)
01-10 17:57:25.966: E/AndroidRuntime(22282): at java.lang.reflect.Method.invoke(Method.java:511)
01-10 17:57:25.966: E/AndroidRuntime(22282): at android.view.View$1.onClick(View.java:3599)
01-10 17:57:25.966: E/AndroidRuntime(22282): ... 12 more
01-10 17:57:25.966: E/AndroidRuntime(22282): Caused by: android.os.NetworkOnMainThreadException
01-10 17:57:25.966: E/AndroidRuntime(22282): at android.os.StrictMode$AndroidBlockGuardPolicy.onNetwork(StrictMode.java:1128)
01-10 17:57:25.966: E/AndroidRuntime(22282): at libcore.io.BlockGuardOs.recvfrom(BlockGuardOs.java:163)
01-10 17:57:25.966: E/AndroidRuntime(22282): at libcore.io.IoBridge.recvfrom(IoBridge.java:557)
01-10 17:57:25.966: E/AndroidRuntime(22282): at java.net.PlainSocketImpl.read(PlainSocketImpl.java:490)
01-10 17:57:25.966: E/AndroidRuntime(22282): at java.net.PlainSocketImpl.access$000(PlainSocketImpl.java:46)
01-10 17:57:25.966: E/AndroidRuntime(22282): at java.net.PlainSocketImpl$PlainSocketInputStream.read(PlainSocketImpl.java:240)
01-10 17:57:25.966: E/AndroidRuntime(22282): at libcore.io.Streams.readSingleByte(Streams.java:41)
01-10 17:57:25.966: E/AndroidRuntime(22282): at java.net.PlainSocketImpl$PlainSocketInputStream.read(PlainSocketImpl.java:236)
01-10 17:57:25.966: E/AndroidRuntime(22282): at com.jcraft.jsch.IO.getByte(IO.java:73)
01-10 17:57:25.966: E/AndroidRuntime(22282): at com.jcraft.jsch.Session.connect(Session.java:263)
01-10 17:57:25.966: E/AndroidRuntime(22282): at com.castizer.castizerapp.SSHManager.connect(SSHManager.java:109)
01-10 17:57:25.966: E/AndroidRuntime(22282): at com.castizer.castizerapp.Main.ButtonOnClick(Main.java:122)
01-10 17:57:25.966: E/AndroidRuntime(22282): ... 15 more