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.
Suddenly in my logs in "warn" I've found this :
unknown permission android.permission.RECORD_VIDEO
And this happened on a device that fails to do a MediaRecorder.start() method with simple and uninformative "start fails" error message.
java.lang.RuntimeException: start failed.
at android.media.MediaRecorder.start(Native Method)
at com.vladdrummer.headsup.ScreenVideoRecorder.record(ScreenVideoRecorder.java:94)
App is working on many devices, but some have this kind of a problem - it fails to start, although , preparing went fine
So, may be theese two errors are connected? what should I do with "unknown permission android.permission.RECORD_VIDEO" ??
There is no permission as
android.permission.RECORD_VIDEO
See here
Ideally you should be using these permission
<uses-permission android:name="android.permission.RECORD_AUDIO" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.CAMERA" />
Also manifest should have
<uses-feature android:name="android.hardware.Camera"/>
I made a simple currency converter application for android. For taking latest currency rates from internet, i need to give permission to connect internet from manifest file.
I added this line to manifest file before
<uses-permission android:name="android.permission.INTERNET" />
I created an apk file of the application and installed it to my phone. Android version of my phone is 4.4.2 and when my wifi is open it gives error. When my wifi is closed the application is opened but can't take xml data. I installed apk file to phone of my friend and anroid version of his phone is 6.0. It works in his phone without any problem.
I added this lines to manifest file
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.ACCESS_WIFI_STATE" />
<uses-permission android:name="android.permission.CHANGE_WIFI_STATE" />
<uses-permission android:name="android.permission.CHANGE_NETWORK_STATE" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
but it didn't work in this way as well.
In build gradle file compileSdkVersion 23, minSdkVersion 19, targetSdkVersion 19.
Could you please help me to solve this problem?
Thank you
Testing my Android app (made in Unity) on the live store shows that it requests "Device ID & call information". As far as I can tell, I don't request these permissions. Here are the permissions I request in my AndroidManifest.xml file. Is this a permission required for all apps? Or is it hidden under one of these other permissions?
<uses-permission android:name="com.android.vending.BILLING" />
<uses-sdk android:minSdkVersion="9" android:targetSdkVersion="19" />
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.ACCESS_WIFI_STATE" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
Thanks!
I just spent an absurd amount of time trying to resolve this so figured I would share with anyone out there going through a similar agony.
Removing the permissions from your manifest will not necessarily remove them from the final build. Unity auto-detects required permissions from all included libraries. The libraries which are most likely causing you to have this permission included are from the Facebook sdk.
If you want to keep the Facebook sdk in the build, there's a relatively straightforward solution. Remove the Facebook SDK (completely) and install a version <= 7.80. For whatever reason, the changes to the sdk in 7.9+ prompt Unity to auto-include the READ_PHONE_STATE permission which triggers the Device ID & Call Information permission warning in google play.
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.