未终止的实体引用错误

Raj*_*san 5 android

我正在使用谷歌地图路线为我自己的Android应用程序.2天前它运行良好,但在那之后应用程序运行时它通过logcat给我错误.任何机构都可以告诉我这个问题的原因和解决方案.

org.xml.sax.SAXParseException: unterminated entity ref (position:ENTITY_REF &@1:799 in java.io.InputStreamReader@406cdeb0)
Run Code Online (Sandbox Code Playgroud)
private String[] getDirectionData(String sourceLat, String sourceLong, String destinationLat, String destinationLong) {


 String urlString = "http://maps.google.com/maps?f=d&hl=en&" +"saddr="+sourceLat+","+sourceLong+"&daddr="+destinationLat+","+destinationLong + "&ie=UTF8&0&om=0&output=kml";
 Log.d("URL", urlString);
 Document doc = null;
 HttpURLConnection urlConnection = null;
 URL url = null;
 String pathConent = "";

 try {

  url = new URL(urlString.toString());
  urlConnection = (HttpURLConnection) url.openConnection();
  urlConnection.setRequestMethod("GET");
  urlConnection.setDoOutput(true);
  urlConnection.setDoInput(true);
  urlConnection.connect();
  DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
  DocumentBuilder db = dbf.newDocumentBuilder();
  doc = db.parse(urlConnection.getInputStream());

 } catch (Exception e) {

     Log.w("Error in google map",e);
 }

 NodeList nl = doc.getElementsByTagName("LineString");
 for (int s = 0; s < nl.getLength(); s++) {
  Node rootNode = nl.item(s);
  NodeList configItems = rootNode.getChildNodes();
  for (int x = 0; x < configItems.getLength(); x++) {
   Node lineStringNode = configItems.item(x);
   NodeList path = lineStringNode.getChildNodes();
   pathConent = path.item(0).getNodeValue();
  }
 }
 String[] tempContent = pathConent.split(" ");
 return tempContent;
}
Run Code Online (Sandbox Code Playgroud)

Edu*_*rdo 7

在我的情况下,此问题出现在/ res/drawable文件夹中的.png文件中.这是一个错误,这里有报道.所以,为了将来的参考,如果你在一个drawable面对它,检查出来.总而言之,请将ADT更新为至少版本21.0.1.

  • 清理项目构建(Project | Clean ... |并选择要清理的项目)可以解决您的问题. (9认同)

ove*_*t13 0

错误消息非常具有暗示性:ref标签未终止,例如<ref>没有封闭</ref>对。使用这样的工具验证您的 XML 输入。