简体   繁体   中英

“Source not found” when debugging Android code in Eclipse

I've been stuck on this issue for a long time and can't seem to find a fix. I have a method where I want to retrieve the HTML source of a website, but every time I run the client.execute step, Eclipse outputs "Source not found". I can hit a breakpoint prior to that step and whether I try to "step over" that line or just hit "go" I still receive "Source not found". This is my method

private void getQuestions()
{
    try 
    {

        URI url = null;
        try 
        {
            url = new URI("http://google.com");
        }
        catch (URISyntaxException e)
        {
            e.printStackTrace();
        }

        HttpClient client = new DefaultHttpClient();
        HttpGet request = new HttpGet();
        request.setURI(url);

        // THIS LINE CAUSES SOURCE NOT FOUND
        HttpResponse response = client.execute(request);

        System.out.println("HttpResponse received");

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

}

In my AndroidManifest.xml file I've also added the following prior to my tags

 <uses-sdk
    android:minSdkVersion="13"
    android:targetSdkVersion="17" />
<uses-permission android:name="android.permission.INTERNET"/>

I've found some people with similar problems and tried their fixes with no success. I've added my application name to my source path and placed it above Default.

资源

I've also moved my Application to be bottom of my build paths

建立路径

I am running Eclipse IDE for Java Developers

Version: Juno Service Release 1

I have created one demo, and its working fine in mine.. please check it, i think it might help you..

URI url = null;
        try 
        {
            url = new URI("http://www.google.com");

            HttpClient client = new DefaultHttpClient();
            HttpGet request = new HttpGet(url);

            HttpResponse response = client.execute(request);

            BufferedReader rd = new BufferedReader(new InputStreamReader(response.getEntity().getContent()));
            String line = "";
            StringBuilder total = new StringBuilder();
            try 
            {
                while ((line = rd.readLine()) != null) 
                { 
                    total.append(line);
                }
            } 
            catch (IOException e) 
            {
                e.printStackTrace();
            }
            Log.w("Html",total.toString());
        }
        catch (Exception e)
        {
            e.printStackTrace();
        }

and i am using this in my Manifest file.

<uses-sdk android:minSdkVersion="7" />
<uses-permission android:name="android.permission.INTERNET" />

and i think you should put your "jsoup-1.7.2.jar" file in libs directory and add jar in project from this libs directory. and just select checkbox to "check (true)" of your jar in Java Build Path dialog. ( It's not necessary but it should checked). like..

在此处输入图片说明

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM