I declared the permission ACCESS_NETWORK_STATE in Application manifest as below.
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>
Everything is good on Android 2.x. But on Android ICS, it failed with below log cat.
java.lang.SecurityException: ConnectivityService: Neither user 10093
nor current process has android.permission.ACCESS_NETWORK_STATE. at
android.os.Parcel.readException(Parcel.java:1327) at
android.os.Parcel.readException(Parcel.java:1281) at
android.net.IConnectivityManager$Stub$Proxy.getActiveNetworkInfo(IConnectivityManager.java:663)
at
android.net.ConnectivityManager.getActiveNetworkInfo(ConnectivityManager.java:455)
at com.tapfortap.AdView.getNetwork(AdView.java:146) at
com.tapfortap.AdView.loadAdsWithAppId(AdView.java:133) at
com.tapfortap.AdView.access$100(AdView.java:47) at
com.tapfortap.AdView$1$1.run(AdView.java:88) at
android.os.Handler.handleCallback(Handler.java:605) at
android.os.Handler.dispatchMessage(Handler.java:92) at
android.os.Looper.loop(Looper.java:137) at
android.app.ActivityThread.main(ActivityThread.java:4503) at
java.lang.reflect.Method.invokeNative(Native Method) at
java.lang.reflect.Method.invoke(Method.java:511) at
com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:809)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:576) at
dalvik.system.NativeStart.main(Native Method)
I updated the permissions like this and it works.
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
this is because ACCESS_NETWORK_STATE is used as connectivityManger and this needs INTERNET connection.
I believe this is an issue with Eclipse; it fails to refresh the manifest to load the permission.
I had the same problem as the original poster and solved it by adding the permission a second time--but then I was able to remove the permission without affecting behavior. This makes me suspect that Eclipse didn't load permissions correctly until I touched the file.
Just add the below permission and it will work fine, i had this a problem before and resolved with me
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>
<uses-permission android:name="android.permission.INTERNET" />
Clean and then Build project solved the issue for me.
Uh-oh,If u adding by default,it will be:
<uses-permission android:name="ANDROID.PERMISSION.ACCESS_NETWORK_STATE"/>
if u re-add permission by:
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>
It works fine.
Unbelievable ! It costs me 2 days
you are missing the Internet permission.add this permisssion it will correct your problem
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>
Just cut the <uses-permission android:name="android.permission.INTERNET" /> and paste all the above permissions. It will work fine...
Clean Project. Check the manifest file. Some package name changes or misplaced data may causes this error.
Clean the project will work.
In your code, There would be places where you would be checking the Internet Availability before making your calls so that your app doesn't crash at runtime. For that, you have to access the 'NETWORK STATE' which requires the permission :
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>
And when the Internet is available, your device communicates with the server using the 'INTERNET' which requires the permission :
<uses-permission android:name="android.permission.INTERNET" />
In my case, neither Clean Project not Rebuild Project worked, and I spent hours to figure out how to get rid of this lint error.
I was also afraid to use the final option Invalidate Caches and Restart because I might roll back to any Local History of a file in future, in case any bug arises.
So finally, I opted for the following option.
I chose File->Invalidate Caches and Restart.
It opened a popup. I then selected the option Just Restart.
And guess what!!It solved my problem. So if any of you are still struggling to get rid of this error, you might wanna try my solution. Do let me know if it worked.
Related
I am opening an old Android Project and between the permissions in the AndroidManifest.xml I found this line: <uses-permission android:name="TASKS"/> but I can't recall what is the use for and sadly I can't find any documentation either.
I have imported a project that was developed on Eclipse into Android Studio.
The project is working perfectly when running\debugging it from Eclipse on my device.
When debugging from the Android Studio on my device, the application is crashing and no exception is being caught on the Android Studio.
When I place breakpoints, they work fine, so I know i'm debugging the correct code :)
Edit:
I have run it again and got the following Exception in the logcat (shouldn't the debugger stop somewhere in the code to show the Exception? like in the line that tries to access the file?):
2018-10-24 11:25:26.027 25903-25903/? E/libpersona: Couldn't open the File - /data/system/users/0/personalist.xml - No such file or directory
2018-10-24 11:25:31.735 23290-23301/? E/DatabaseUtils: Writing exception to parcel
java.lang.SecurityException: Permission Denial: reading com.android.providers.media.MediaProvider uri content://media/external/images/media from pid=25858, uid=10314 requires android.permission.READ_EXTERNAL_STORAGE, or grantUriPermission()
at android.content.ContentProvider.enforceReadPermissionInner(ContentProvider.java:639)
at android.content.ContentProvider$Transport.enforceReadPermission(ContentProvider.java:505)
at android.content.ContentProvider$Transport.query(ContentProvider.java:217)
at android.content.ContentProviderNative.onTransact(ContentProviderNative.java:102)
at android.os.Binder.execTransact(Binder.java:682)
Although I do have permissions set in the AndroidMenifest.xml:
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
package="com.eibimalul.smartgallery"
android:versionCode="1"
android:versionName="1.0" >
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE"/>
<uses-permission android:name="android.permission.READ_SOCIAL_STREAM"/>
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
Edit 2: The Solution:
So apparently I was missing 2 things:
run-time permissions which I understood using this link here and with the help of #Pier Giorgio Misley's comment
I was missing permissions on the AndroidManifest.xml:
<uses-permission android:name="android.permission.READ_PHONE_STATE" />
The solution:
Apparently I was missing 2 things:
Run-time permissions which I understood using this link here and
with the help of #Pier Giorgio Misley's comment
I was missing permissions on the AndroidManifest.xml:
<uses-permission android:name="android.permission.READ_PHONE_STATE" />
I am not sure if that's the right way to do it (answering my own question that is), since I got help from few developers here (#Pier Giorgio Misley in particular) in the comments only, but I thought it is important to mark the question as answered.
I have finished developing an Android app. I'm using android studio. Everything is working fine when I normally run the app in debug mode on my device. Not even an exception.
But when I followed Google's guidelines on creating the signed release version of my app and installed it in my device, the app is force closing as soon as I launch it.
I just can't figure out a way to locate what the problem is. I created the release version using the "Generate signed apk" option in the Android studio IDE. Then I copied it in my device and installed the app. And then when I run, it just stops working immediately.
I don't know what more info should I give here because I just can't infer the cause of this issue.
Please help. What can be the possible reasons behind such problems.? And how can I find them?
EDIT:
Everytime I unlock the device, it is displaying the dialog "MyApp has stopped working". There's nothing in the logcat. I have no idea why this might be happening. My app uses these permissions:
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.WAKE_LOCK" />
<uses-permission android:name="android.permission.VIBRATE" />
<uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED" />
<uses-permission android:name="android.permission.GET_ACCOUNTS" />
<uses-permission android:name="com.google.android.c2dm.permission.RECEIVE" />
<permission
android:name="com.mypackagename.permission.C2D_MESSAGE"
android:protectionLevel="signature" />
<uses-permission android:name="com.mypackagename.permission.C2D_MESSAGE" />
I solved the issue on my own.
First of all, you can use a tool named "monitor", present in the android sdk tools to debug your release version. This tool shows everything that happens in your device.
I used the tool and found out that the problem occurred because I had enabled proguard in my app and forgot to add rules for third party libraries used in my app.
So all those who might be facing this problem, check your proguard file and make sure you've added the required rules for all third party libraries as well.
I am getting the following error when I run my application on my phone:
java.lang.SecurityException: Permission denied (missing INTERNET permission?)
I have already added that permission in my manifest file as follows:
<uses-permission android:name="ANDROID.PERMISSION.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
I am getting the error only when I run the app on my phone. It runs fine on my GenyMotion emulator. I read similar questions on SO before posting it. Also, I have made a couple of apps before with same permissions, and this error had never occurred then. So I don't get why Android is messing it up this time.
P.S.: I updated my SDK tools before starting with this new application. Somehow felt that it was important to mention it!
Use small caps
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
I have an Mobile AIR project in FlashBuilder 4.6(Using AIR 3.4) and I am having a real problem publishing an APK. Here is the section from my APP XML:
<manifestAdditions><![CDATA[
<manifest android:installLocation="auto">
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
<uses-permission android:name="android.permission.READ_PHONE_STATE"/>
<uses-permission android:name="android.permission.DISABLE_KEYGUARD"/>
<uses-permission android:name="android.permission.WAKE_LOCK"/>
</manifest>
]]></manifestAdditions>
For some reason, when I create an APK, the INTERNET permission is being tacked on the end of the manifest permissions block. Note that the application.xml in the asset/META-INF/AIR folder still looks correct.
Any ideas where I am going wrong?
After a lot more searching, I found my own answer:
Note: When you bundle the runtime, ADT adds the INTERNET and
BROADCAST_STICKY permissions to your application. These permissions
are required by the AIR runtime.
BROADCAST_STICKY seems to no longer be required, but apparently when using captive runtime we cannot get around this.