ACCESS_FINE_LOCATION permission error emulator only(仅限 ACCESS_FINE_LOCATION 权限错误模拟器)
问题描述
我只在使用模拟器时遇到了一个奇怪的错误.我发现了一个 9 个月前有相同问题的问题,但根本没有答案...
我正在使用谷歌播放服务位置来获取我的应用程序中的位置,并且我确定我的清单权限并且一切都在我的手机上完美运行,仅使用模拟器时会出现问题,我在两者上都尝试了不同的模拟器我的 iMac 和 Windows 机器.
我怀疑模拟器不支持这个基本功能!
这是我的清单代码:
<?xml version="1.0" encoding="utf-8"?><清单 xmlns:android="http://schemas.android.com/apk/res/android"包="com.orderme.ordermeandroid" ><uses-permission android:name="android.permission.INTERNET"></uses-permission><使用权限android:name="android.permission.ACCESS_COARSE_LOCATION"/><使用权限android:name="android.permission.ACCESS_FINE_LOCATION"/>
这里是触发异常的地方:
LocationRequest mLLocationRequest = new LocationRequest();mLocationRequest.setInterval(10000);mLocationRequest.setFastestInterval(5000);mLLocationRequest.setPriority(LocationRequest.PRIORITY_HIGH_ACCURACY);LocationServices.FusedLocationApi.requestLocationUpdates(googleApiClient,mLocationRequest,this);
堆栈跟踪:
08-26 14:01:19.699 10157-10157/com.orderme.ordermeandroid E/AndroidRuntime: 致命例外:主要进程:com.orderme.ordermeandroid,PID:10157java.lang.SecurityException:客户端必须具有 ACCESS_FINE_LOCATION 权限才能请求 PRIORITY_HIGH_ACCURACY 位置.在 android.os.Parcel.readException(Parcel.java:1599)在 android.os.Parcel.readException(Parcel.java:1552)在 com.google.android.gms.location.internal.zzg$zza$zza.zza(未知来源)在 com.google.android.gms.location.internal.zzi.zza(未知来源)在 com.google.android.gms.location.internal.zzj.zza(未知来源)在 com.google.android.gms.location.internal.zzd$1.zza(未知来源)在 com.google.android.gms.location.internal.zzd$1.zza(未知来源)在 com.google.android.gms.common.api.zzc$zza.zzb(未知来源)在 com.google.android.gms.common.api.zzf.zza(未知来源)在 com.google.android.gms.common.api.zzf.zzb(未知来源)在 com.google.android.gms.common.api.zzi.zzb(未知来源)在 com.google.android.gms.location.internal.zzd.requestLocationUpdates(未知来源)在 com.orderme.ordermeandroid.Main.MainActivity.onConnected(MainActivity.java:184)在 com.google.android.gms.common.internal.zzk.zzh(未知来源)在 com.google.android.gms.common.api.zzg.zznt(未知来源)在 com.google.android.gms.common.api.zzg.onConnected(未知来源)在 com.google.android.gms.common.api.zzi$2.onConnected(未知来源)在 com.google.android.gms.common.internal.zzj$zzg.zzoD(未知来源)在 com.google.android.gms.common.internal.zzj$zza.zzc(未知来源)在 com.google.android.gms.common.internal.zzj$zza.zzs(未知来源)在 com.google.android.gms.common.internal.zzj$zzc.zzoF(未知来源)在 com.google.android.gms.common.internal.zzj$zzb.handleMessage(未知来源)在 android.os.Handler.dispatchMessage(Handler.java:102)在 android.os.Looper.loop(Looper.java:148)在 android.app.ActivityThread.main(ActivityThread.java:5417)在 java.lang.reflect.Method.invoke(本机方法)在 com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:726)在 com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616)
我的猜测是您在 Android 6.0+ 模拟器上运行此程序,并且您的 targetSdkVersion
为 23 或更高.p>
在这种情况下,ACCESS_COARSE_LOCATION
和 ACCESS_FINE_LOCATION
是 Android 6.0 运行时权限系统.修改您的应用以加入此系统,或将您的 targetSdkVersion
降至 23 以下.
I'm having a weird error while using the emulator ONLY. I found one question that has the same issue 9 months ago with no answers at all...
I'm using google play services locations to get locations in my app and I'm sure of my manifest permissions and everything works perfectly on my phone, the problem occurs when using an emulator only, and I tried different emulators on both my iMac and Windows machines.
I doubt that emulators don't support this basic function!
here is my manifest code:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.orderme.ordermeandroid" >
<uses-permission android:name="android.permission.INTERNET"></uses-permission>
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION"/>
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION"/>
and here is where the exception is firing:
LocationRequest mLocationRequest = new LocationRequest();
mLocationRequest.setInterval(10000);
mLocationRequest.setFastestInterval(5000);
mLocationRequest.setPriority(LocationRequest.PRIORITY_HIGH_ACCURACY);
LocationServices.FusedLocationApi.requestLocationUpdates(googleApiClient,mLocationRequest,this);
stack trace:
08-26 14:01:19.699 10157-10157/com.orderme.ordermeandroid E/AndroidRuntime﹕ FATAL EXCEPTION: main
Process: com.orderme.ordermeandroid, PID: 10157
java.lang.SecurityException: Client must have ACCESS_FINE_LOCATION permission to request PRIORITY_HIGH_ACCURACY locations.
at android.os.Parcel.readException(Parcel.java:1599)
at android.os.Parcel.readException(Parcel.java:1552)
at com.google.android.gms.location.internal.zzg$zza$zza.zza(Unknown Source)
at com.google.android.gms.location.internal.zzi.zza(Unknown Source)
at com.google.android.gms.location.internal.zzj.zza(Unknown Source)
at com.google.android.gms.location.internal.zzd$1.zza(Unknown Source)
at com.google.android.gms.location.internal.zzd$1.zza(Unknown Source)
at com.google.android.gms.common.api.zzc$zza.zzb(Unknown Source)
at com.google.android.gms.common.api.zzf.zza(Unknown Source)
at com.google.android.gms.common.api.zzf.zzb(Unknown Source)
at com.google.android.gms.common.api.zzi.zzb(Unknown Source)
at com.google.android.gms.location.internal.zzd.requestLocationUpdates(Unknown Source)
at com.orderme.ordermeandroid.Main.MainActivity.onConnected(MainActivity.java:184)
at com.google.android.gms.common.internal.zzk.zzh(Unknown Source)
at com.google.android.gms.common.api.zzg.zznt(Unknown Source)
at com.google.android.gms.common.api.zzg.onConnected(Unknown Source)
at com.google.android.gms.common.api.zzi$2.onConnected(Unknown Source)
at com.google.android.gms.common.internal.zzj$zzg.zzoD(Unknown Source)
at com.google.android.gms.common.internal.zzj$zza.zzc(Unknown Source)
at com.google.android.gms.common.internal.zzj$zza.zzs(Unknown Source)
at com.google.android.gms.common.internal.zzj$zzc.zzoF(Unknown Source)
at com.google.android.gms.common.internal.zzj$zzb.handleMessage(Unknown Source)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:148)
at android.app.ActivityThread.main(ActivityThread.java:5417)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:726)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616)
My guess is that you are running this on an Android 6.0+ emulator and you have a targetSdkVersion
of 23 or higher.
In that case, ACCESS_COARSE_LOCATION
and ACCESS_FINE_LOCATION
are part of the Android 6.0 runtime permission system. Either revise your app to participate in this system, or drop your targetSdkVersion
below 23.
这篇关于仅限 ACCESS_FINE_LOCATION 权限错误模拟器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:仅限 ACCESS_FINE_LOCATION 权限错误模拟器
基础教程推荐
- 如何在没有IB的情况下将2个按钮添加到右侧的UINavigationbar? 2022-01-01
- 如何在 iPhone 上显示来自 API 的 HTML 文本? 2022-01-01
- 当从同一个组件调用时,两个 IBAction 触发的顺序是什么? 2022-01-01
- Android:对话框关闭而不调用关闭 2022-01-01
- UIWebView 委托方法 shouldStartLoadWithRequest:在 WKWebView 中等效? 2022-01-01
- 在 gmail 中为 ios 应用程序检索朋友的朋友 2022-01-01
- 如何让对象对 Cocos2D 中的触摸做出反应? 2022-01-01
- 如何在 UIImageView 中异步加载图像? 2022-01-01
- Kivy Buildozer 无法构建 apk,命令失败:./distribute.sh -m “kivy"d 2022-01-01
- android 应用程序已发布,但在 google play 中找不到 2022-01-01