【发布时间】:2013-04-06 16:13:27
【问题描述】:
我已经被这个问题困扰了很长时间,似乎无法找到解决办法。我有一种方法,我想检索网站的 HTML 源代码,但每次运行 client.execute 步骤时,Eclipse 都会输出“找不到源”。我可以在该步骤之前打断点,无论我尝试“越过”该行还是只是点击“go”,我仍然会收到“Source not found”。这是我的方法
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();
}
}
在我的 AndroidManifest.xml 文件中,我还在标签之前添加了以下内容
<uses-sdk
android:minSdkVersion="13"
android:targetSdkVersion="17" />
<uses-permission android:name="android.permission.INTERNET"/>
我发现一些人有类似的问题,并尝试了他们的修复,但没有成功。我已将我的应用程序名称添加到我的源路径并将其置于 Default 之上。
我还将我的应用程序移动到构建路径的底部
我正在为 Java 开发人员运行 Eclipse IDE
版本:Juno Service Release 1
【问题讨论】:
-
这通常意味着应用程序已经崩溃,您可以使用Eclipse debugging "source not found"链接到HttpClient的源代码。但这不是您的应用崩溃的原因,请打开 LogCat 窗口查看堆栈跟踪。
-
@Sam here is a screenshot of my logcat,但它似乎没有提供任何用处?
-
检查底部的解决方案 - stackoverflow.com/questions/9161430/using-httpget-on-android。它可能对你有用。