반응형
오류 상황
geolocator 패키지를 사용하여 사용자의 위치 정보를 확인하는 어플 제작 중 다음과 같은 오류(user denied permissions to access the device's location.)가 발생하며 사용자에게 위치 정보를 묻는 창이 뜨지 않는 오류
해결 노력
1. 프로젝트 새로 만들기
2. AVD 삭제 및 재생성
3. geolocator 버전 변경
4. AndroidManifest.xml에 사용자 위치 정보 동의 코드(
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
) 삭제 후 다시 붙여넣기 반복
->모두 실패
오류 해결
사용자의 위치정보를 받아오는 코드인
Position position = await Geolocator.getCurrentPosition(desiredAccuracy: LocationAccuracy.high);
위에
LocationPermission permission = await Geolocator.requestPermission();
해당 코드 추가
void getLocation () async{
LocationPermission permission = await Geolocator.requestPermission(); //오류 해결 코드
Position position = await Geolocator.
getCurrentPosition(desiredAccuracy: LocationAccuracy.high);
print(position);
}
결과
출처
코딩셰프 채널 영상 댓글 정oo 님
반응형
'앱 프로그래밍 > Flutter' 카테고리의 다른 글
플러터로 기상청 날씨 앱 만들기 일지 3. 역지오코딩(위도, 경도 -> 주소 불러오기) (0) | 2022.01.08 |
---|---|
플러터로 기상청 날씨 앱 만들기 일지 2. 데이터 연동(기상청 API) (0) | 2022.01.05 |
플러터로 기상청 날씨 앱 만들기 일지 1. UI 디자인 (0) | 2022.01.02 |
[코딩셰프]플러터 강좌 내용 정리-9(반복문을 이용한 로또 번호 생성기 제작) (0) | 2021.12.28 |
[코딩셰프]플러터 강좌 내용 정리-8(코드 리팩토링) (0) | 2021.12.27 |
[오류해결] the plugin `fluttertoast` uses a deprecated version of the android embedding. (2) | 2021.12.27 |