如果启动以下代码,我会收到以下Android异常。我有一个服务器 - 客户端应用程序和一个相互通信的服务器代理。现在我只是在Android应用程序中获得此异常,而不是在服务器代理上。我知道这在一段时间之后才能正常工作。
12-18 20:36:41.626: E/AndroidRuntime(19441): FATAL EXCEPTION: AsyncTask #1
12-18 20:36:41.626: E/AndroidRuntime(19441): java.lang.RuntimeException: An error occured while executing doInBackground()
12-18 20:36:41.626: E/AndroidRuntime(19441): at android.os.AsyncTask$3.done(AsyncTask.java:299)
12-18 20:36:41.626: E/AndroidRuntime(19441): at java.util.concurrent.FutureTask.finishCompletion(FutureTask.java:352)
12-18 20:36:41.626: E/AndroidRuntime(19441): at java.util.concurrent.FutureTask.setException(FutureTask.java:219)
12-18 20:36:41.626: E/AndroidRuntime(19441): at java.util.concurrent.FutureTask.run(FutureTask.java:239)
12-18 20:36:41.626: E/AndroidRuntime(19441): at android.os.AsyncTask$SerialExecutor$1.run(AsyncTask.java:230)
12-18 20:36:41.626: E/AndroidRuntime(19441): at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1080)
12-18 20:36:41.626: E/AndroidRuntime(19441): at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:573)
12-18 20:36:41.626: E/AndroidRuntime(19441): at java.lang.Thread.run(Thread.java:841)
12-18 20:36:41.626: E/AndroidRuntime(19441): Caused by: java.lang.NoClassDefFoundError: de.hska.ilias.commons.server.Communication
12-18 20:36:41.626: E/AndroidRuntime(19441): at de.hska.ilias.app.client.Client.handleServerPassword(Client.java:101)
12-18 20:36:41.626: E/AndroidRuntime(19441): at de.hska.ilias.app.client.Client.manageHandshake(Client.java:75)
12-18 20:36:41.626: E/AndroidRuntime(19441): at de.hska.ilias.app.client.LoginTask.doInBackground(LoginTask.java:85)
12-18 20:36:41.626: E/AndroidRuntime(19441): at de.hska.ilias.app.client.LoginTask.doInBackground(LoginTask.java:1)
12-18 20:36:41.626: E/AndroidRuntime(19441): at android.os.AsyncTask$2.call(AsyncTask.java:287)
12-18 20:36:41.626: E/AndroidRuntime(19441): at java.util.concurrent.FutureTask.run(FutureTask.java:234)
12-18 20:36:41.626: E/AndroidRuntime(19441): ... 4 more
12-18 20:36:41.956: E/WindowManager(19441): Activity de.hska.ilias.app.activity.MainActivity has leaked window com.android.internal.policy.impl.PhoneWindow$DecorView{43168430 V.E..... R......D 0,0-1026,288} that was originally added here
12-18 20:36:41.956: E/WindowManager(19441): android.view.WindowLeaked: Activity de.hska.ilias.app.activity.MainActivity has leaked window com.android.internal.policy.impl.PhoneWindow$DecorView{43168430 V.E..... R......D 0,0-1026,288} that was originally added here
12-18 20:36:41.956: E/WindowManager(19441): at android.view.ViewRootImpl.<init>(ViewRootImpl.java:450)
12-18 20:36:41.956: E/WindowManager(19441): at android.view.WindowManagerGlobal.addView(WindowManagerGlobal.java:258)
12-18 20:36:41.956: E/WindowManager(19441): at android.view.WindowManagerImpl.addView(WindowManagerImpl.java:73)
12-18 20:36:41.956: E/WindowManager(19441): at android.app.Dialog.show(Dialog.java:287)
12-18 20:36:41.956: E/WindowManager(19441): at de.hska.ilias.app.client.LoginTask.onPreExecute(LoginTask.java:73)
12-18 20:36:41.956: E/WindowManager(19441): at android.os.AsyncTask.executeOnExecutor(AsyncTask.java:586)
12-18 20:36:41.956: E/WindowManager(19441): at android.os.AsyncTask.execute(AsyncTask.java:534)
12-18 20:36:41.956: E/WindowManager(19441): at de.hska.ilias.app.client.Client.tryConnect(Client.java:44)
12-18 20:36:41.956: E/WindowManager(19441): at de.hska.ilias.app.ui.action.LoginAction.onClick(LoginAction.java:77)
12-18 20:36:41.956: E/WindowManager(19441): at android.view.View.performClick(View.java:4475)
12-18 20:36:41.956: E/WindowManager(19441): at android.view.View$PerformClick.run(View.java:18786)
12-18 20:36:41.956: E/WindowManager(19441): at android.os.Handler.handleCallback(Handler.java:730)
12-18 20:36:41.956: E/WindowManager(19441): at android.os.Handler.dispatchMessage(Handler.java:92)
12-18 20:36:41.956: E/WindowManager(19441): at android.os.Looper.loop(Looper.java:137)
12-18 20:36:41.956: E/WindowManager(19441): at android.app.ActivityThread.main(ActivityThread.java:5419)
12-18 20:36:41.956: E/WindowManager(19441): at java.lang.reflect.Method.invokeNative(Native Method)
12-18 20:36:41.956: E/WindowManager(19441): at java.lang.reflect.Method.invoke(Method.java:525)
12-18 20:36:41.956: E/WindowManager(19441): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1187)
12-18 20:36:41.956: E/WindowManager(19441): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1003)
12-18 20:36:41.956: E/WindowManager(19441): at dalvik.system.NativeStart.main(Native Method)
例外来自:
private void handleServerPassword() throws ServerPasswordException
{
try
{
**if (Communication.rcvLineServerPasswordReq(input))**
{
Communication.sndServerPasswordAck(output);
Communication.sndServerPassword(output);
}
else
throw new ServerPasswordException();
}
catch (ServerPasswordException e)
{
throw new ServerPasswordException("Handling password communication failed.");
}
}
答案 0 :(得分:0)
NoClassDefFoundError指定该类在运行时期间不可用。确保在类路径中有它,或者静态初始化程序(如果存在)没有中断。对于后者,您将在stacktrace中的下方某处看到ExceptionInInitializerError。我建议你仔细阅读Debug a NoClassDefFoundError
答案 1 :(得分:0)
我找到了解决这个问题的方法:它是Java编译器合规级别,在Android项目中设置为1.6,在依赖Java项目中设置为1.7。将两者都设置为1.6后,它解决了问题,但我不知道为什么;)