Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

java.lang.SecurityException: ConnectivityService: Neither user 10134 nor current process has android.permission.ACCESS_NETWORK_STATE

Tags:

android

I got a report of this exception from 1 user even though I have the permission in the manifest

<uses-sdk
        android:minSdkVersion="10"
        android:targetSdkVersion="19" />

    <uses-permission android:name="android.permission.INTERNET" />
    <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
like image 586
code511788465541441 Avatar asked Jul 03 '14 11:07

code511788465541441


2 Answers

I had this problem as well... when building against an earlier API, I was simply getting an unhandledException thrown, which I noticed when stepping over the getAllNetworkInfo() or getActiveNetworkInfo(). However, nothing was actually shown in logcat. When building against the newest API (22), I got the above-mentioned SecurityException.

For me, the solution turned out to be that I had written

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

when instead I needed

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

So, to any developer experiencing this issue and scratching his head, please note that these permission names are case sensitive!

like image 199
astyanaxas Avatar answered Dec 02 '22 04:12

astyanaxas


I solved moving the uses-permission just below the manifest tag

like image 34
adev Avatar answered Dec 02 '22 02:12

adev