Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Permission denied - missing INTERNET permission?

I'm having problem with the internet permission. Yes I've looked around and I made sure the permission is outside the application tag.

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="app.com.example.android.sunshine" >

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

    <application
        android:allowBackup="true"
        android:icon="@mipmap/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>

</manifest> 

And here's the logcat:

02-13 15:10:07.622 5879-5951/app.com.example.android.sunshine E/AndroidRuntime﹕ FATAL EXCEPTION: AsyncTask #1 Process: app.com.example.android.sunshine, PID: 5879 java.lang.RuntimeException: An error occured while executing doInBackground() at android.os.AsyncTask$3.done(AsyncTask.java:300) at java.util.concurrent.FutureTask.finishCompletion(FutureTask.java:355) at java.util.concurrent.FutureTask.setException(FutureTask.java:222) at java.util.concurrent.FutureTask.run(FutureTask.java:242) at android.os.AsyncTask$SerialExecutor$1.run(AsyncTask.java:231) at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1112) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:587) at java.lang.Thread.run(Thread.java:841) Caused by: java.lang.SecurityException: Permission denied (missing INTERNET permission?) at java.net.InetAddress.lookupHostByName(InetAddress.java:418) at java.net.InetAddress.getAllByNameImpl(InetAddress.java:236) at java.net.InetAddress.getAllByName(InetAddress.java:214) at com.android.okhttp.internal.Dns$1.getAllByName(Dns.java:28) at com.android.okhttp.internal.http.RouteSelector.resetNextInetSocketAddress(RouteSelector.java:216) at com.android.okhttp.internal.http.RouteSelector.next(RouteSelector.java:122) at com.android.okhttp.internal.http.HttpEngine.connect(HttpEngine.java:292) at com.android.okhttp.internal.http.HttpEngine.sendSocketRequest(HttpEngine.java:255) at com.android.okhttp.internal.http.HttpEngine.sendRequest(HttpEngine.java:206) at com.android.okhttp.internal.http.HttpURLConnectionImpl.execute(HttpURLConnectionImpl.java:345) at com.android.okhttp.internal.http.HttpURLConnectionImpl.connect(HttpURLConnectionImpl.java:89) at app.com.example.android.sunshine.ForecastFragment$FetchWeatherTask.doInBackground(ForecastFragment.java:117) at app.com.example.android.sunshine.ForecastFragment$FetchWeatherTask.doInBackground(ForecastFragment.java:94) at android.os.AsyncTask$2.call(AsyncTask.java:288) at java.util.concurrent.FutureTask.run(FutureTask.java:237)             at android.os.AsyncTask$SerialExecutor$1.run(AsyncTask.java:231)             at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1112)             at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:587)             at java.lang.Thread.run(Thread.java:841) Caused by: libcore.io.GaiException: getaddrinfo failed: EAI_NODATA (No address associated with hostname) at libcore.io.Posix.getaddrinfo(Native Method) at libcore.io.ForwardingOs.getaddrinfo(ForwardingOs.java:61) at java.net.InetAddress.lookupHostByName(InetAddress.java:405)             at java.net.InetAddress.getAllByNameImpl(InetAddress.java:236)             at java.net.InetAddress.getAllByName(InetAddress.java:214)             at com.android.okhttp.internal.Dns$1.getAllByName(Dns.java:28)             at com.android.okhttp.internal.http.RouteSelector.resetNextInetSocketAddress(RouteSelector.java:216)             at com.android.okhttp.internal.http.RouteSelector.next(RouteSelector.java:122)             at com.android.okhttp.internal.http.HttpEngine.connect(HttpEngine.java:292)             at com.android.okhttp.internal.http.HttpEngine.sendSocketRequest(HttpEngine.java:255)             at com.android.okhttp.internal.http.HttpEngine.sendRequest(HttpEngine.java:206)             at com.android.okhttp.internal.http.HttpURLConnectionImpl.execute(HttpURLConnectionImpl.java:345)             at com.android.okhttp.internal.http.HttpURLConnectionImpl.connect(HttpURLConnectionImpl.java:89)             at app.com.example.android.sunshine.ForecastFragment$FetchWeatherTask.doInBackground(ForecastFragment.java:117)             at app.com.example.android.sunshine.ForecastFragment$FetchWeatherTask.doInBackground(ForecastFragment.java:94)             at android.os.AsyncTask$2.call(AsyncTask.java:288)             at java.util.concurrent.FutureTask.run(FutureTask.java:237)             at android.os.AsyncTask$SerialExecutor$1.run(AsyncTask.java:231)             at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1112)             at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:587)             at java.lang.Thread.run(Thread.java:841) Caused by: libcore.io.ErrnoException: getaddrinfo failed: EACCES (Permission denied)             at libcore.io.Posix.getaddrinfo(Native Method)             at libcore.io.ForwardingOs.getaddrinfo(ForwardingOs.java:61)             at java.net.InetAddress.lookupHostByName(InetAddress.java:405)             at java.net.InetAddress.getAllByNameImpl(InetAddress.java:236)             at java.net.InetAddress.getAllByName(InetAddress.java:214)             at com.android.okhttp.internal.Dns$1.getAllByName(Dns.java:28)             at com.android.okhttp.internal.http.RouteSelector.resetNextInetSocketAddress(RouteSelector.java:216)             at com.android.okhttp.internal.http.RouteSelector.next(RouteSelector.java:122)             at com.android.okhttp.internal.http.HttpEngine.connect(HttpEngine.java:292)             at com.android.okhttp.internal.http.HttpEngine.sendSocketRequest(HttpEngine.java:255)             at com.android.okhttp.internal.http.HttpEngine.sendRequest(HttpEngine.java:206)             at com.android.okhttp.internal.http.HttpURLConnectionImpl.execute(HttpURLConnectionImpl.java:345)             at com.android.okhttp.internal.http.HttpURLConnectionImpl.connect(HttpURLConnectionImpl.java:89)             at app.com.example.android.sunshine.ForecastFragment$FetchWeatherTask.doInBackground(ForecastFragment.java:117)             at app.com.example.android.sunshine.ForecastFragment$FetchWeatherTask.doInBackground(ForecastFragment.java:94)             at android.os.AsyncTask$2.call(AsyncTask.java:288)             at java.util.concurrent.FutureTask.run(FutureTask.java:237)             at android.os.AsyncTask$SerialExecutor$1.run(AsyncTask.java:231)             at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1112)             at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:587)             at java.lang.Thread.run(Thread.java:841) 02-13 15:15:07.659 5879-5951/app.com.example.android.sunshine I/Process﹕ Sending signal. PID: 5879 SIG: 9

Thanks for the help.

like image 588
fokusfocus Avatar asked Nov 28 '22 13:11

fokusfocus


2 Answers

Please use:

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

Please read here:

SecurityException: Permission denied (missing INTERNET permission?)

Depending on what you are doing you may need to add:

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

Official Docs: http://developer.android.com/reference/android/Manifest.permission.html

like image 127
Jared Burrows Avatar answered Jan 15 '23 16:01

Jared Burrows


write it like this (with caps)

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

you can also try adding this:

<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
like image 39
Mago Avatar answered Jan 15 '23 16:01

Mago