Cannot resolve Manifest.permission.ACCESS_FINE_LOCATION
Solution 1
For the first part, you should be using <uses-permission>
according the the Android Devlopers site. Try making sure you declare your permissions directly under the <manifest>
tag, not in your <application>
tag. It's hard to know what your problem is without seeing your entire manifest file. Check out the link I posted above for more info on how to declare permissions in your manifest.
In regards to your runtime permissions problem:
With uses-permissions Cannot resolve that..
new String[]{Manifest.permission.ACCESS_FINE_LOCATION}
Why?
Make sure you're using android.Manifest
instead of my.app.package.Manifest
. A lot of times Android Studio will default to the latter instead of the former.
So, your new line of code would look like:
new String[]{android.Manifest.permission.ACCESS_FINE_LOCATION};
Edit: I reformatted my answer.
Edit 2: Be wary of importing android.Manifest
. It can cause issues if you're also importing my.app.package.Manifest
. Other than that import android.Manifest
is another valid way to resolve this issue.
Solution 2
change this
Manifest.permission.ACCESS_FINE_LOCATION
into this
android.Manifest.permission.ACCESS_FINE_LOCATION
Solution 3
Try this! Since ACCESS_FINE_LOCATION available in following package so Add:
import android.Manifest;
Solution 4
I had a similar problem where used;
ContextCompat.checkSelfPermission(MainActivity.this,Manifest.permission.READ_CONTACTS) != PackageManager.PERMISSION_GRANTED
where it could not resolve symbol READ_CONTACTS
.
However on using;
import android.Manifest;
It started to recognize READ_CONTACT
Solution 5
if you are working on dynamic permissions and any permission like ACCESS_FINE_LOCATION,ACCESS_COARSE_LOCATION giving error "cannot resolve method PERMISSION_NAME" in this case write you code with permission name and then rebuild your project this will regenerate the manifest(Manifest.permission) file
Related videos on Youtube
Comments
-
Pablo Cegarra about 3 years
When adding permissions to my manifest file, the below xml works.
<permission android:name="android.permission.ACCESS_FINE_LOCATION" />
However, this xml doesn't work.
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
Which one am I supposed to be using? If it's the first one, why wouldn't it work? How can I fix it?
Also, I am getting an Android 6.0 runtime permissions related exception:
java.lang.SecurityException: "gps" location provider requires ACCESS_FINE_LOCATION permission.
When I try to add the permission to a String array in order to check the permission, Android Studio tells me it can't resolve
Manifest.permission
in the below code:new String[]{Manifest.permission.ACCESS_FINE_LOCATION}
Why would it be doing this? How can I fix it?
-
jjj about 7 yearsthis kind of solution is better as comment if you are not sure.
-
hnilsen over 6 yearsUsing andorid.Manifest.permission.X instead of Manifest.permission.X solved this for me, thanks.
-
Pang over 6 yearsHi Jagrit Vishwakarma, do you mean one should remove the
new String[]{
part? -
Pang over 6 yearsThis seems to be just a repeat of this existing answer.
-
anshuman burmman over 4 yearsI am new in android so i am not able to understand where i have to put "new String[]{android.Manifest.permission.ACCESS_FINE_LOCATION};" this line in the android studio.