这是我的清单文件
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.pa4ad.earthquakeviewer"
android:versionCode="1"
android:versionName="1.0" >
<uses-sdk
android:minSdkVersion="11"
android:targetSdkVersion="21" />
<uses-permission android:name="android.permisson.INTERNET"/>
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>
<application
android:allowBackup="true"
android:icon="@drawable/ic_launcher"
android:label="@string/app_name"
android:theme="@style/AppTheme" >
<activity
android:name=".Earthquake"
android:label="@string/app_name" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
</manifest>
我在Nexus 7第1代测试了这些代码,而不是仿真器。在线完成搜索后,我找到了类似问题的解决方案,并添加了INTERNET和ACCESS_NETWORK_STATE权限,但仍然出现此错误。
03-25 11:15:49.909: E/AndroidRuntime(27298): java.lang.SecurityException: Permission denied (missing INTERNET permission?)
03-25 11:15:49.909: E/AndroidRuntime(27298): at java.net.InetAddress.lookupHostByName(InetAddress.java:451)
03-25 11:15:49.909: E/AndroidRuntime(27298): at java.net.InetAddress.getAllByNameImpl(InetAddress.java:252)
03-25 11:15:49.909: E/AndroidRuntime(27298): at java.net.InetAddress.getAllByName(InetAddress.java:215)
03-25 11:15:49.909: E/AndroidRuntime(27298): at com.android.okhttp.HostResolver$1.getAllByName(HostResolver.java:29)
03-25 11:15:49.909: E/AndroidRuntime(27298): at com.android.okhttp.internal.http.RouteSelector.resetNextInetSocketAddress(RouteSelector.java:232)
03-25 11:15:49.909: E/AndroidRuntime(27298): at com.android.okhttp.internal.http.RouteSelector.next(RouteSelector.java:124)
03-25 11:15:49.909: E/AndroidRuntime(27298): at com.android.okhttp.internal.http.HttpEngine.connect(HttpEngine.java:272)
03-25 11:15:49.909: E/AndroidRuntime(27298): at com.android.okhttp.internal.http.HttpEngine.sendRequest(HttpEngine.java:211)
03-25 11:15:49.909: E/AndroidRuntime(27298): at com.android.okhttp.internal.http.HttpURLConnectionImpl.execute(HttpURLConnectionImpl.java:382)
03-25 11:15:49.909: E/AndroidRuntime(27298): at com.android.okhttp.internal.http.HttpURLConnectionImpl.getResponse(HttpURLConnectionImpl.java:332)
03-25 11:15:49.909: E/AndroidRuntime(27298): at com.android.okhttp.internal.http.HttpURLConnectionImpl.getResponseCode(HttpURLConnectionImpl.java:500)
答案 0 :(得分:4)
许可中存在拼写错误
<uses-permission android:name="android.permisson.INTERNET"/>
使用此
<uses-permission android:name="android.permission.INTERNET"/>
参考:http://developer.android.com/training/basics/network-ops/connecting.html
答案 1 :(得分:0)
授予互联网许可:
<uses-permission android:name="android.permission.INTERNET" />