【问题标题】:Android Calling REST service. Source Not FoundAndroid 调用 REST 服务。未找到来源
【发布时间】:2014-03-03 17:37:54
【问题描述】:

现在已经到了我无法忍受的地步!我见过很多人遇到过和这个一样的问题,但他们的解决方案对我不起作用。

我正在尝试从我的 Android 应用程序调用 REST 服务。顺便说一句,我还是 Android 新手。 调用代码如下所示:

String httpResult = "";
HttpClient httpClient = new DefaulthttpClient();
HttpContext httpContext = new BasicHttpContext();
String url = myURL;
HttpGet httpGet = new HttpGet(myURL);
HttpResponse response = httpClient.execute(httpGet, httpContext);

//receive response in input stream
InputStream is = response.getEntity().getContent();
//convert the stream into a string
if(is != null){
//call method that will convert stream to string
   httpResult = cString(is);
}else{
   httpResult = "Error";
}

当我调试代码时,我看到当编译器遇到"HttpClient httpClient = new DefaultHttpClient()" 代码行并显示"No Source Found" 屏幕时会引发异常。

【问题讨论】:

  • 有什么例外?
  • 你在manifest.xml中设置了上网权限吗?
  • 在清单中,靠近 标签
  • @Mach:异常是找不到类。
  • @user974801:是的,我已经这样做了

标签: java android rest


【解决方案1】:

在没有源文件的情况下调试类时出现“No Source Found”。

在调试时您应该只使用 F6 跳过。

【讨论】:

  • 好的,那么我在哪里可以找到类“org.apache.http.impl.client.DefaultHttpClient”的源文件,因为我认为这是它无法解决的问题
  • 获取android sdk源码并导入eclipse。您可以通过Android SDK Manager获取(找到正确的版本并选择“Sources for Android SDK”项目)
  • 我使用 F6 跳过代码,结果发现是 XML 序列化程序给我带来了问题。所以我只是将我的 REST 服务改为返回 JSON,现在一切正常!!!呀呀呀呀呀! :)
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 2016-03-17
  • 1970-01-01
  • 2018-07-13
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多