0
這裏是我的代碼和日誌信息的AsyncTask#1時發生錯誤,執行doInBackground()
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.raspored);
Bundle bundle = getIntent().getExtras();
url = bundle.getString("url");
new FetchWebsiteData().execute();
}
private class FetchWebsiteData extends AsyncTask<Void, Void, Void> {
String eles = "";
/*@Override
protected void onPreExecute() {
super.onPreExecute();
mProgressDialog = new ProgressDialog(Raspored.this);
mProgressDialog.setMessage("Loading...");
mProgressDialog.setIndeterminate(false);
mProgressDialog.show();
}*/
@Override
protected Void doInBackground(Void... params) {
try {
// Connect to website
Document document = Jsoup.connect(url).get();
// Get the html document title
//websiteTitle = document.title();
Element elementsByTag = document.body();
Element tablica = elementsByTag.getElementsByTag("table").get(9).getElementsByTag("td").get(4);
Elements redak = tablica.getElementsByTag("ul");
eles = redak.text().toString();
} catch (IOException e)
{
e.printStackTrace();
}
return null;
}
@Override
protected void onPostExecute(Void result) {
// Set title into TextView
TextView txttitle = (TextView) findViewById(R.id.tbl_txt);
txttitle.setMovementMethod(new ScrollingMovementMethod());
//txttitle.setText(websiteTitle + "\n" + eles);
String ele = eles.replace(" ", "\n");
arr_linkText.add(ele);
for(String temp : arr_linkText) {
txttitle.append(temp);
}
//mProgressDialog.dismiss();
}
}
}
登錄:
10-30 21:04:54.554: E/AndroidRuntime(27047): FATAL EXCEPTION: AsyncTask #1
10-30 21:04:54.554: E/AndroidRuntime(27047): java.lang.RuntimeException: An error occured while executing doInBackground()
10-30 21:04:54.554:E/AndroidRuntime(27047):atandroid.os.AsyncTask$3.done (AsyncTask.java:299)
10-30 21:04:54.554: E/AndroidRuntime(27047): at java.util.concurrent.FutureTask$Sync.innerSetException(FutureTask.java:273)
10-30 21:04:54.554: E/AndroidRuntime(27047): at java.util.concurrent.FutureTask.setException(FutureTask.java:124)
10-30 21:04:54.554: E/AndroidRuntime(27047): at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:307)
10-30 21:04:54.554: E/AndroidRuntime(27047): at java.util.concurrent.FutureTask.run(FutureTask.java:137)
10-30 21:04:54.554: E/AndroidRuntime(27047): at android.os.AsyncTask$SerialExecutor$1.run(AsyncTask.java:230)
10-30 21:04:54.554: E/AndroidRuntime(27047): at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1076)
10-30 21:04:54.554: E/AndroidRuntime(27047): at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:569)
10-30 21:04:54.554: E/AndroidRuntime(27047): at java.lang.Thread.run(Thread.java:856)
10-30 21:04:54.554: E/AndroidRuntime(27047): Caused by: java.lang.NoClassDefFoundError: org.jsoup.Jsoup
10-30 21:04:54.554: E/AndroidRuntime(27047): at com.project.busme.Raspored$FetchWebsiteData.doInBackground(Raspored.java:52)
10-30 21:04:54.554: E/AndroidRuntime(27047): at com.project.busme.Raspored$FetchWebsiteData.doInBackground(Raspored.java:1)
10-30 21:04:54.554: E/AndroidRuntime(27047): at android.os.AsyncTask$2.call(AsyncTask.java:287)
10-30 21:04:54.554: E/AndroidRuntime(27047): at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:305)
10-30 21:04:54.554: E/AndroidRuntime(27047): ... 5 more
什麼是這裏的問題?
確保您在項目中包含了Jsoup的所有依賴關係。 – ToasteR 2014-10-30 20:19:26
'引起:java.lang.NoClassDefFoundError:org.jsoup.Jsoup 10-30 21:04:54.554:E/AndroidRuntime(27047):' – asgs 2014-10-30 20:20:42
這是什麼意思?我在項目中添加了jsoup.jar文件 – 2014-10-30 20:26:22