"Source not found" when debugging an Android application using Eclipse

The code is as follows, and I set a breakpoint on a specific line (I marked it in the code below, in fact, Eclipse always tells me โ€œsource not foundโ€, wherever I set a 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(); } } }); } } 

Startup is debugging, and then I got an invitation: the source was not found. What for? can Eclipse stop at a breakpoint in i code? why does eclipse require more source code?

+4
source share
2 answers

Does it help?

  • Start debugging and run until you hit the breakpoint

  • Right-click in the Debug window of the Debug perspective (for example, in the call stack) and select Change Source Search Path

  • Add all your projects above "Default", through "Add ..."> "Java Project"> "Select All"

+13
source

You need to add the android source to your project. The problem is that when you enter the android class file (for example, import android.app.Activity), you backtrack from your code and the android class file.

+1
source

Source: https://habr.com/ru/post/1393722/


All Articles