"Source not found" when debugging android app using Eclipse

14,818

Solution 1

Does this help?

  1. Start debugging, and run until you hit a breakpoint

  2. Right click in the Debug view of the Debug perspective (for example on the call stack), and choose "Edit Source Lookup Path"

  3. Add all your projects above "Default", via "Add..." > "Java project" > "Select All"

Solution 2

You need to add the android source to your project. The problem is that when you step into an android class file (such as import android.app.Activity), you are stepping away from your code and into an android class file.

Share:
14,818
Searene
Author by

Searene

A social nerd.

Updated on June 04, 2022

Comments

  • Searene
    Searene about 2 years

    Code is as follows, and i set a breakpoint on certain line(i have marked it in the code below, in fact, Eclipse always tells me "source no found", wherever i set the breakpoint):

    package com.app.MainActivity;
    
    import java.io.IOException;
    
    import org.xmlpull.v1.XmlPullParser;
    import org.xmlpull.v1.XmlPullParserException;
    
    import android.app.Activity;
    import android.content.res.XmlResourceParser;
    import android.os.Bundle;
    import android.view.View;
    import android.view.View.OnClickListener;
    import android.widget.Button;
    import android.widget.TextView;
    
    public class Chapter03_ResourceActivity extends Activity {
        /** Called when the activity is first created. */
    
        private Button myButton;
        final private TextView myTextView = (TextView)findViewById(R.id.text_xml);
    
        @Override
        public void onCreate(Bundle savedInstanceState) {
            super.onCreate(savedInstanceState);
            setContentView(R.layout.main);
    
            myButton = (Button)findViewById(R.id.btn_xml);
    
            myButton.setOnClickListener(new OnClickListener() {
                @Override
                public void onClick(View v) {
                StringBuilder sb = new StringBuilder();                   <==Here breakpoint
                XmlResourceParser xrp = getResources().getXml(R.xml.test);
                int counter = 0;
                try {
                    while(xrp.getEventType() != XmlPullParser.END_DOCUMENT) {
                        if(xrp.getEventType() == XmlPullParser.START_TAG) {
                            String name = xrp.getName();
                            if(name.equals("customer")) {
                                counter ++;
                                sb.append(counter + " Customer" + "\n");
                                sb.append(xrp.getAttributeValue(0) + "\n");
                                sb.append(xrp.getAttributeValue(1) + "\n");
                                sb.append(xrp.getAttributeValue(2) + "\n\n");
                            } 
                            xrp.next();
                        }
                    } 
                myTextView.setText(sb.toString());
                } catch(IOException e) {
                    e.printStackTrace();
                } catch(XmlPullParserException e) {
                    e.printStackTrace();
                } 
                }
            });
        }
    }
    

    Run--Debug, and then i got a prompt: Source not found. why? cannot Eclipse stop on the breakpoint in the code i supply? why does eclipse need more source code?