program tip

Manifest.permission.ACCESS_FINE_LOCATION을 해결할 수 없습니다.

radiobox 2020. 10. 25. 12:02
반응형

Manifest.permission.ACCESS_FINE_LOCATION을 해결할 수 없습니다.


내 매니페스트 파일에 권한을 추가하면 아래 xml이 작동합니다.

 <permission android:name="android.permission.ACCESS_FINE_LOCATION" />

그러나이 xml은 작동하지 않습니다.

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

어느 것을 사용해야합니까? 첫 번째라면 왜 작동하지 않을까요? 어떻게 고칠 수 있습니까?

또한 Android 6.0 런타임 권한 관련 예외가 발생합니다.

java.lang.SecurityException: "gps" location provider requires ACCESS_FINE_LOCATION permission.

권한을 확인하기 위해 String 배열에 권한을 추가하려고하면 Android Studio Manifest.permission에서 아래 코드에서 해결할 수 없다고 알려줍니다 .

new String[]{Manifest.permission.ACCESS_FINE_LOCATION}

왜 이럴까요? 어떻게 고칠 수 있습니까?


첫 번째 부분에서는 <uses-permission> Android Devlopers 사이트에 따라 사용해야합니다 . 태그가 아닌 태그 바로 아래에서 권한을 선언했는지 확인 <manifest>하세요 <application>. 전체 매니페스트 파일을 보지 않고는 문제가 무엇인지 알기가 어렵습니다. 매니페스트에서 권한을 선언하는 방법에 대한 자세한 내용 은 위에 게시 한 링크를 확인 하세요.

런타임 권한 문제와 관련하여 :

사용 권한으로 해결할 수 없습니다 ..

new String [] {Manifest.permission.ACCESS_FINE_LOCATION}

왜?

android.Manifest대신을 사용하고 있는지 확인하십시오 my.app.package.Manifest. 대부분의 경우 Android Studio는 전자 대신 후자를 기본으로합니다.

따라서 새 코드 줄은 다음과 같습니다.

new String[]{android.Manifest.permission.ACCESS_FINE_LOCATION};

편집 : 내 대답의 형식을 변경했습니다.

편집 2 : 가져 오기에주의하십시오 android.Manifest. 을 (를) 가져 오는 경우 문제 발생할 있습니다 my.app.package.Manifest. 그 외에는 import android.Manifest이 문제를 해결하는 또 다른 유효한 방법입니다.


이것을 변경

Manifest.permission.ACCESS_FINE_LOCATION

이것으로

android.Manifest.permission.ACCESS_FINE_LOCATION


이 시도! ACCESS_FINE_LOCATION은 다음 패키지에서 사용할 수 있으므로 추가하십시오.

import android.Manifest;

­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­


나는 비슷한 문제가 사용되었습니다.

ContextCompat.checkSelfPermission(MainActivity.this,Manifest.permission.READ_CONTACTS) != PackageManager.PERMISSION_GRANTED 

symbol을 확인할 수 없습니다 READ_CONTACTS.

그러나 사용시;

import android.Manifest;

인식하기 시작했습니다 READ_CONTACT


동적 권한 및 ACCESS_FINE_LOCATION, ACCESS_COARSE_LOCATION 과 같은 권한에 대해 작업하는 경우이 경우 "PERMISSION_NAME 메소드를 해결할 수 없습니다"라는 오류가 발생 하는 경우 권한 이름으로 코드를 작성한 다음 프로젝트다시 빌드 하면 매니페스트 (Manifest.permission) 파일 다시 생성 됩니다.


이미 hnilsen 에서 언급했듯이 매니페스트 파일에 이미 uses.permissions 설정이 올바르게 설정되어 있으면 다음 줄을 바꿉니다.

 Manifest.permission.ACCESS_FINE_LOCATION

이것에 의해 :

 android.Manifest.permission.ACCESS_FINE_LOCATION

이것은 당신의 문제를 해결할 수 있습니다.


 if (Build.VERSION.SDK_INT >= 23) {

            if (checkSelfPermission(android.Manifest.permission.ACCESS_FINE_LOCATION) == PackageManager.PERMISSION_GRANTED
                    || checkSelfPermission(android.Manifest.permission.ACCESS_COARSE_LOCATION) == PackageManager.PERMISSION_GRANTED) {

                mapView.setMyLocationEnabled(true); 
            }
        }
        else
        {
            mapView.setMyLocationEnabled(true);

        }

실행하기 전에 시도해보십시오. 액세스 권한이 있는지 확인하십시오.

try {
    location = locationManager.getLastKnownLocation(LocationManager.GPS_PROVIDER);
} catch (SecurityException e) {
   dialogGPS(this.getContext()); // lets the user know there is a problem with the gps
}

변화

new String[]{Manifest.permission.ACCESS_FINE_LOCATION}

이에

new String[]{android.Manifest.permission.ACCESS_FINE_LOCATION}

문제가 해결됩니다.


new String[]{Manifest.permission.ACCESS_FINE_LOCATION}

그것을 변경

android.manifest.permission.ACCESS_FINE_LOCATION

이 시도:

if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M && ContextCompat.checkSelfPermission(this, android.Manifest.permission.READ_EXTERNAL_STORAGE) != PackageManager.PERMISSION_GRANTED) {
        ActivityCompat.requestPermissions(this, new String[]{android.Manifest.permission.READ_EXTERNAL_STORAGE}, REQUEST_SELECT_PICTURE);
        return;
    }

When you type "Manifest", Android Studio should suggest you to choose a few options of Manifest. You should choose the one start android instead of the name of your project.

If you access the reference of Manifest.java and you can find there is only 1-2 lines in "Permission" class, then you are referencing the wrong manifest class.

참고URL : https://stackoverflow.com/questions/34139048/cannot-resolve-manifest-permission-access-fine-location

반응형