权限被拒绝(缺少INTERNET权限?) - android错误

时间:2014-11-19 15:23:58

标签: android permissions

当我尝试在设备上运行我的应用程序时,我收到以下错误:权限被拒绝(缺少INTERNET权限?)。我在AndroidManifest.xml中拥有互联网权限。这是AndroidManifest文件:

<?xml version="1.0" encoding="utf-8"?>
    <manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="jamp.vsite.hr.weathervak" >

    <uses-permission android:name="android.name.INTERNET"></uses-permission>
    <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=".MainActivity"
        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>

这是我的logcat

11-19 16:08:12.610      862-862/jamp.vsite.hr.weathervak E/Trace﹕ error opening trace file: No             such file or directory (2)
11-19 16:08:12.650      862-862/jamp.vsite.hr.weathervak W/ActivityThread﹕ Application     jamp.vsite.hr.weathervak can be debugged on port 8100...
11-19 16:08:13.300      862-886/jamp.vsite.hr.weathervak D/libc﹕ [NET] getaddrinfo  hn 22, servname NULL, ai_family 0+
11-19 16:08:13.310      862-886/jamp.vsite.hr.weathervak W/dalvikvm﹕ threadid=11: thread exiting with uncaught exception (group=0x41308540)
11-19 16:08:13.400      862-886/jamp.vsite.hr.weathervak E/AndroidRuntime﹕ FATAL EXCEPTION: AsyncTask #1
java.lang.RuntimeException: An error occured while executing doInBackground()
        at android.os.AsyncTask$3.done(AsyncTask.java:299)
        at java.util.concurrent.FutureTask$Sync.innerSetException(FutureTask.java:273)
        at java.util.concurrent.FutureTask.setException(FutureTask.java:124)
        at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:307)
        at java.util.concurrent.FutureTask.run(FutureTask.java:137)
        at android.os.AsyncTask$SerialExecutor$1.run(AsyncTask.java:230)
        at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1076)
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:569)
        at java.lang.Thread.run(Thread.java:864)
 Caused by: java.lang.SecurityException: Permission denied (missing INTERNET permission?)
        at java.net.InetAddress.lookupHostByName(InetAddress.java:428)
        at java.net.InetAddress.getAllByNameImpl(InetAddress.java:239)
        at java.net.InetAddress.getAllByName(InetAddress.java:214)
        at libcore.net.http.HttpConnection.<init>(HttpConnection.java:70)
        at libcore.net.http.HttpConnection.<init>(HttpConnection.java:50)
        at libcore.net.http.HttpConnection$Address.connect(HttpConnection.java:340)
        at libcore.net.http.HttpConnectionPool.get(HttpConnectionPool.java:87)
        at libcore.net.http.HttpConnection.connect(HttpConnection.java:128)
        at libcore.net.http.HttpEngine.openSocketConnection(HttpEngine.java:315)
        at libcore.net.http.HttpEngine.connect(HttpEngine.java:310)
        at libcore.net.http.HttpEngine.sendSocketRequest(HttpEngine.java:289)
        at libcore.net.http.HttpEngine.sendRequest(HttpEngine.java:239)
        at libcore.net.http.HttpURLConnectionImpl.connect(HttpURLConnectionImpl.java:80)
        at jamp.vsite.hr.weathervak.PlaceholderFragment$ForecastTask.doInBackground(PlaceholderFragment.java:110)
        at jamp.vsite.hr.weathervak.PlaceholderFragment$ForecastTask.doInBackground(PlaceholderFragment.java:39)
        at android.os.AsyncTask$2.call(AsyncTask.java:287)
        at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:305)

我搜索了解决方案,但没有成功。有人知道问题出在哪里了吗?

1 个答案:

答案 0 :(得分:5)

许可android.name.INTERNET不存在。使用此:

<uses-permission android:name="android.permission.INTERNET"/>