我收到错误消息
public void run() {
// TODO Auto-generated method stub
URL myurl = null;
try {
myurl = new URL("http://10.0.2.2/list.JSON");
}
catch (MalformedURLException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
try {
URLConnection myconn = myurl.openConnection();
InputStream in = new BufferedInputStream(myconn.getInputStream());
InputStreamReader reader = new InputStreamReader(in);
BufferedReader br = new BufferedReader(reader);
String line;
StringBuilder sb = new StringBuilder();
while ((line=br.readLine()) != null)
{
sb.append(line);
//Toast.makeText(getApplicationContext(), "I enter here", Toast.LENGTH_LONG).show();
}
jsoncode = sb.toString();
}
catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
threading = true;
super.run();
}
06-30 11:33:21.457: W/System.err(619): java.net.SocketException: socket failed: EACCES (Permission denied)
06-30 11:33:21.467: W/System.err(619): at libcore.io.IoBridge.socket(IoBridge.java:573)
06-30 11:33:21.467: W/System.err(619): at java.net.PlainSocketImpl.create(PlainSocketImpl.java:201)
06-30 11:33:21.479: W/System.err(619): at java.net.Socket.checkOpenAndCreate(Socket.java:663)
06-30 11:33:21.479: W/System.err(619): at java.net.Socket.connect(Socket.java:807)
06-30 11:33:21.479: W/System.err(619): at libcore.net.http.HttpConnection.<init>(HttpConnection.java:77)
06-30 11:33:21.479: W/System.err(619): at libcore.net.http.HttpConnection.<init>(HttpConnection.java:50)
06-30 11:33:21.479: W/System.err(619): at libcore.net.http.HttpConnection$Address.connect(HttpConnection.java:351)
06-30 11:33:21.479: W/System.err(619): at libcore.net.http.HttpConnectionPool.get(HttpConnectionPool.java:86)
06-30 11:33:21.479: W/System.err(619): at libcore.net.http.HttpConnection.connect(HttpConnection.java:128)
06-30 11:33:21.487: W/System.err(619): at libcore.net.http.HttpEngine.openSocketConnection(HttpEngine.java:308)
06-30 11:33:21.487: W/System.err(619): at libcore.net.http.HttpEngine.connect(HttpEngine.java:303)
06-30 11:33:21.497: W/System.err(619): at libcore.net.http.HttpEngine.sendSocketRequest(HttpEngine.java:282)
06-30 11:33:21.497: W/System.err(619): at libcore.net.http.HttpEngine.sendRequest(HttpEngine.java:232)
06-30 11:33:21.497: W/System.err(619): at libcore.net.http.HttpURLConnectionImpl.getResponse(HttpURLConnectionImpl.java:273)
06-30 11:33:21.497: W/System.err(619): at libcore.net.http.HttpURLConnectionImpl.getInputStream(HttpURLConnectionImpl.java:168)
06-30 11:33:21.497: W/System.err(619): at com.apk.PItestActivity$connection.run(PItestActivity.java:190)
06-30 11:33:21.507: W/System.err(619): Caused by: libcore.io.ErrnoException: socket failed: EACCES (Permission denied)
06-30 11:33:21.517: W/System.err(619): at libcore.io.Posix.socket(Native Method)
06-30 11:33:21.517: W/System.err(619): at libcore.io.BlockGuardOs.socket(BlockGuardOs.java:169)
06-30 11:33:21.527: W/System.err(619): at libcore.io.IoBridge.socket(IoBridge.java:558)
06-30 11:33:21.527: W/System.err(619): ... 15 more
这是我的清单文件:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.apk"
android:versionCode="1"
android:versionName="1.0" >
<uses-sdk android:minSdkVersion="14" />
<permission android:name="android.permission.INTERNET"></permission>
<application
android:icon="@drawable/ic_launcher"
android:label="@string/app_name" >
<activity
android:name=".PItestActivity"
android:label="@string/app_name" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity android:name="addfriend"></activity>
<activity android:name="updateDetails"></activity>
<activity android:name="Details"></activity>
<activity android:name="updateimage"></activity>
</application>
</manifest>
如何修复此问题?
试试看,
<uses-permission android:name="android.permission.INTERNET"/>
而不是,
<permission android:name="android.permission.INTERNET"></permission>
我该怎么修好它?或者请将我转到关于该主题的教程。
我得到了一个Android应用程序,但当我启动它时,我得到了一个错误在我的控制台。我正在使用一个数据报套接字创建连接,并且使用了两个类:(这是应用程序的主要活动)和来创建连接。 这里的代码MainActivity: 但它不起作用。
以及我的logcat: 我真的很感谢你的时间,因为这将节省我的大量时间:)干杯,
我已经找到了所有的解决方案并应用到我的项目中。但它们不起作用。我被拒绝了这个许可。我已经把所有可能的许可都放进了清单文件。请告诉我我的项目出了什么问题。 我的manifest.xml Logcat:
我找了几个地方,试了很多东西,但我不明白这里出了什么问题:(请帮帮我。