-1

我在我的 Android 应用程序中遇到了一个问题,我无法从网站获取特定数据。我的应用程序崩溃了。这是我的代码:

    private void AddListenerOnButton() {
    spinner = (Spinner) getView().findViewById(R.id.spinner);
    final WebView webView = (WebView) getView().findViewById(R.id.webView1);
    webView.getSettings().setJavaScriptEnabled(true);
    webView.getSettings().setRenderPriority(RenderPriority.HIGH);
    webView.getSettings().setCacheMode(WebSettings.LOAD_NO_CACHE);
    webView.getSettings().setDatabaseEnabled(true);
    webView.getSettings().setDomStorageEnabled(true);
    webView.getSettings().setAppCacheEnabled(true);
    webView.getSettings().setBuiltInZoomControls(true);

    spinner.setOnItemSelectedListener(new OnItemSelectedListener() {
        @Override
        public void onItemSelected(AdapterView<?> parentView, View selectedItemView, int position, long id) {
            String text1 = spinner.getSelectedItem().toString().trim();
            //WebClient wc = new WebClient();

            if (text1.equals("US Dollar - USD")) {          
                try {
                    Document doc = Jsoup.connect("http://en.wikipedia.org/").get();
                    Elements newsHeadlines = doc.select("#mp-itn b a");

                } catch (IOException e) {
                    // TODO Auto-generated catch block
                    e.printStackTrace();
                }   

这是我的日志:

07-09 23:04:52.161: E/AndroidRuntime(798): FATAL EXCEPTION: main
07-09 23:04:52.161: E/AndroidRuntime(798): java.lang.NoClassDefFoundError: org.jsoup.Jsoup
07-09 23:04:52.161: E/AndroidRuntime(798):  at com.example.currencyconverter.Fragment2$1.onItemSelected(Fragment2.java:77)
07-09 23:04:52.161: E/AndroidRuntime(798):  at android.widget.AdapterView.fireOnSelected(AdapterView.java:892)
07-09 23:04:52.161: E/AndroidRuntime(798):  at android.widget.AdapterView.access$200(AdapterView.java:49)
07-09 23:04:52.161: E/AndroidRuntime(798):  at android.widget.AdapterView$SelectionNotifier.run(AdapterView.java:860)
07-09 23:04:52.161: E/AndroidRuntime(798):  at android.os.Handler.handleCallback(Handler.java:725)
07-09 23:04:52.161: E/AndroidRuntime(798):  at android.os.Handler.dispatchMessage(Handler.java:92)
07-09 23:04:52.161: E/AndroidRuntime(798):  at android.os.Looper.loop(Looper.java:137)
07-09 23:04:52.161: E/AndroidRuntime(798):  at android.app.ActivityThread.main(ActivityThread.java:5041)
07-09 23:04:52.161: E/AndroidRuntime(798):  at java.lang.reflect.Method.invokeNative(Native Method)
07-09 23:04:52.161: E/AndroidRuntime(798):  at java.lang.reflect.Method.invoke(Method.java:511)
07-09 23:04:52.161: E/AndroidRuntime(798):  at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:793)
07-09 23:04:52.161: E/AndroidRuntime(798):  at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:560)
07-09 23:04:52.161: E/AndroidRuntime(798):  at dalvik.system.NativeStart.main(Native Method)

这里发生了什么?我似乎无法理解发生了什么。任何帮助将不胜感激。

4

1 回答 1

0

这条线是线索...

java.lang.NoClassDefFoundError: org.jsoup.Jsoup

您的应用程序在运行时找不到 Jsoup 库。不幸的是,我可以用我所看到的来告诉你为什么,但这里有一个链接,它有很多很好的理由和修复......

Android java.lang.NoClassDefFoundError: org.jsoup.Jsoup

于 2013-07-10T00:23:27.170 回答