这是我的代码:
我已经包含了几乎所有的
实际上,
非常感谢您的任何建议。
import com.gargoylesoftware.htmlunit.WebClient;
import com.gargoylesoftware.htmlunit.html.HtmlPage;
final WebClient webClient = new WebClient();
final HtmlPage startPage = webClient.getPage("http://htmlunit.sf.net");
我遇到的错误如下:
11-04 21:58:08.761: ERROR/dalvikvm(17868): Could not find class 'com.gargoylesoftware.htmlunit.DefaultCssErrorHandler', referenced from method com.gargoylesoftware.htmlunit.WebClient.<init>
11-04 21:58:08.771: ERROR/dalvikvm(17868): Could not find class 'com.gargoylesoftware.htmlunit.DefaultCssErrorHandler', referenced from method com.gargoylesoftware.htmlunit.WebClient.<init>
11-04 21:58:09.501: ERROR/AndroidRuntime(17868): FATAL EXCEPTION: AsyncTask #1
11-04 21:58:09.501: ERROR/AndroidRuntime(17868): java.lang.RuntimeException: An error occured while executing doInBackground()
11-04 21:58:09.501: ERROR/AndroidRuntime(17868): at android.os.AsyncTask$3.done(AsyncTask.java:200)
11-04 21:58:09.501: ERROR/AndroidRuntime(17868): at java.util.concurrent.FutureTask$Sync.innerSetException(FutureTask.java:274)
11-04 21:58:09.501: ERROR/AndroidRuntime(17868): at java.util.concurrent.FutureTask.setException(FutureTask.java:125)
11-04 21:58:09.501: ERROR/AndroidRuntime(17868): at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:308)
11-04 21:58:09.501: ERROR/AndroidRuntime(17868): at java.util.concurrent.FutureTask.run(FutureTask.java:138)
11-04 21:58:09.501: ERROR/AndroidRuntime(17868): at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1088)
11-04 21:58:09.501: ERROR/AndroidRuntime(17868): at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:581)
11-04 21:58:09.501: ERROR/AndroidRuntime(17868): at java.lang.Thread.run(Thread.java:1027)
11-04 21:58:09.501: ERROR/AndroidRuntime(17868): Caused by: java.lang.NoClassDefFoundError: com.gargoylesoftware.htmlunit.DefaultCssErrorHandler
11-04 21:58:09.501: ERROR/AndroidRuntime(17868): at com.gargoylesoftware.htmlunit.WebClient.<init>(WebClient.java:157)
11-04 21:58:09.501: ERROR/AndroidRuntime(17868): at com.gargoylesoftware.htmlunit.WebClient.<init>(WebClient.java:180)
11-04 21:58:09.501: ERROR/AndroidRuntime(17868): at com.Testapp4.fa.ForumAdapter.isGood(ForumAdapter.java:209)
11-04 21:58:09.501: ERROR/AndroidRuntime(17868): at com.Testapp4.BoardIndex$pbar.doInBackground(BoardIndex.java:82)
11-04 21:58:09.501: ERROR/AndroidRuntime(17868): at com.Testapp4.BoardIndex$pbar.doInBackground(BoardIndex.java:1)
11-04 21:58:09.501: ERROR/AndroidRuntime(17868): at android.os.AsyncTask$2.call(AsyncTask.java:185)
11-04 21:58:09.501: ERROR/AndroidRuntime(17868): at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:306)
11-04 21:58:09.501: ERROR/AndroidRuntime(17868): ... 4 more
11-04 21:58:09.872: ERROR/WindowManager(17868): Activity com.Testapp4.BoardIndex has leaked window com.android.internal.policy.impl.PhoneWindow$DecorView@40562468 that was originally added here
11-04 21:58:09.872: ERROR/WindowManager(17868): android.view.WindowLeaked: Activity com.Testapp4.BoardIndex has leaked window com.android.internal.policy.impl.PhoneWindow$DecorView@40562468 that was originally added here
11-04 21:58:09.872: ERROR/WindowManager(17868): at android.view.ViewRoot.<init>(ViewRoot.java:275)
11-04 21:58:09.872: ERROR/WindowManager(17868): at android.view.WindowManagerImpl.addView(WindowManagerImpl.java:148)
11-04 21:58:09.872: ERROR/WindowManager(17868): at android.view.WindowManagerImpl.addView(WindowManagerImpl.java:91)
11-04 21:58:09.872: ERROR/WindowManager(17868): at android.view.Window$LocalWindowManager.addView(Window.java:430)
11-04 21:58:09.872: ERROR/WindowManager(17868): at android.app.Dialog.show(Dialog.java:288)
11-04 21:58:09.872: ERROR/WindowManager(17868): at android.app.ProgressDialog.show(ProgressDialog.java:107)
11-04 21:58:09.872: ERROR/WindowManager(17868): at android.app.ProgressDialog.show(ProgressDialog.java:90)
11-04 21:58:09.872: ERROR/WindowManager(17868): at com.Testapp4.BoardIndex$pbar.onPreExecute(BoardIndex.java:66)
11-04 21:58:09.872: ERROR/WindowManager(17868): at android.os.AsyncTask.execute(AsyncTask.java:391)
11-04 21:58:09.872: ERROR/WindowManager(17868): at com.Testapp4.BoardIndex.Load(BoardIndex.java:191)
11-04 21:58:09.872: ERROR/WindowManager(17868): at com.Testapp4.BoardIndex.onCreate(BoardIndex.java:56)
11-04 21:58:09.872: ERROR/WindowManager(17868): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1093)
11-04 21:58:09.872: ERROR/WindowManager(17868): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1780)
11-04 21:58:09.872: ERROR/WindowManager(17868): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1837)
11-04 21:58:09.872: ERROR/WindowManager(17868): at android.app.ActivityThread.access$1500(ActivityThread.java:132)
11-04 21:58:09.872: ERROR/WindowManager(17868): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1033)
11-04 21:58:09.872: ERROR/WindowManager(17868): at android.os.Handler.dispatchMessage(Handler.java:99)
11-04 21:58:09.872: ERROR/WindowManager(17868): at android.os.Looper.loop(Looper.java:143)
11-04 21:58:09.872: ERROR/WindowManager(17868): at android.app.ActivityThread.main(ActivityThread.java:4196)
11-04 21:58:09.872: ERROR/WindowManager(17868): at java.lang.reflect.Method.invokeNative(Native Method)
11-04 21:58:09.872: ERROR/WindowManager(17868): at java.lang.reflect.Method.invoke(Method.java:507)
11-04 21:58:09.872: ERROR/WindowManager(17868): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:839)
11-04 21:58:09.872: ERROR/WindowManager(17868): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:597)
11-04 21:58:09.872: ERROR/WindowManager(17868): at dalvik.system.NativeStart.main(Native Method)
我已经包含了几乎所有的
jar
文件,只有一些因为导致Eclipse崩溃而被删除。我想我已经包含了那2行代码所需的一切。实际上,
HtmlUnit
在Android上工作时遇到了困难。非常感谢您的任何建议。