Android调试器和JSOUP:找不到源代码

时间:2012-04-19 05:03:01

标签: java android eclipse jsoup

我正在尝试检索网站的HTML代码并解析它以获取网站的文本。出于某种原因,当我注释掉代码的jsoup库部分时,我下面的类运行正常,但是否则我得到这个奇怪的错误“找不到源代码”,并且调试部分没有命中任何断点。甚至不是任何jsoup代码之前的那些。当我点击模拟器上的按钮时,它会立即跳转到错误。我将jsoup jar文件添加到我的eclipse项目中作为我的java构建路径中的外部JAR。我究竟做错了什么?

BTW:我有jsoup 1.6.2

public class AndroidActivity extends Activity 
{
    @Override
    public void onCreate(Bundle savedInstanceState) 
    {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);

        final EditText eText = (EditText) findViewById(R.id.address);
        final TextView tView = (TextView) findViewById(R.id.pagetext);
        // TODO Auto-generated method stub

        class TareaAsincrona extends AsyncTask<String, Void ,String>
        {
            @Override
            protected void onPreExecute()
            {
            }
            @Override
            protected void onPostExecute(String X)
            {
            }
            @Override
            protected String doInBackground(String... urls) 
            {
                try
                {
                    // Perform action on click
                    URL url = new URL(eText.getText().toString());
                    URLConnection conn = url.openConnection();
                    // Get the response
                    BufferedReader rd = new BufferedReader(new InputStreamReader(conn.getInputStream()));
                    String line = "";
                    String Codigo_Fuente ="";
                    while ((line = rd.readLine()) != null) 
                    {
                        Codigo_Fuente= Codigo_Fuente + line;
                        //Codigo_Fuente.add(line);//android.text.Html.fromHtml(line).toString());
                    }
                    Document doc = Jsoup.parse(Codigo_Fuente);
                    return doc.body().text();
                }
                catch(Exception e)
                {
                    e.printStackTrace();
                    return null;
                }
            }
        }

        final Button button = (Button) findViewById(R.id.ButtonGo);
        button.setOnClickListener(new Button.OnClickListener()
        {
            public void onClick(View arg0) 
            {
                new TareaAsincrona().execute();
            }
        });
    }
}

1 个答案:

答案 0 :(得分:1)

您是否也将库添加到“libs”文件夹中?