我确实拥有运行时权限,这段代码可以在大多数设备上运行几个月.此错误主要发生在OnePlus One上,我可以在安装了Android 6的HTC One M8上重新生成.
我认为问题与最新的谷歌播放服务更新有关,但我无法验证这一点.仅当设备位置服务被禁用(实际上自动从谷歌播放服务中删除位置权限)时才会出现此错误,因此我认为这些设备上的最新播放服务有一个错误会导致安全例外因为谷歌播放服务没有虽然我的应用程序可以访问位置数据的权限.
有没有人遇到类似的问题,也许找到了更好的解决方案然后尝试{}抓住整个事情或谷歌关于这个问题的任何更新?
更新:
我可以在带有Android 6.0的HTC One M8上再次测试这个,并且还启用SecurityException,启用位置服务和对应用程序和播放服务的grantet权限.
除非将异常消息转发到,否则在BALANCED_POWER和HIGH_ACCURACY之间切换无效
Client must have ACCESS_COARSE_LOCATION or ACCESS_FINE_LOCATION
permission to perform any location operations.
文件访问权限没有问题,使用Android LocationManager的后备实现不会抛出SecurityException,但仅在位置服务设置为gps时确定位置.
有趣的事实:使用Google地图时,Google Play服务每隔几秒就会崩溃,因此无法找到任何位置.只有导航,才能启用gps才能找到位置.
综上所述
带有Google Play服务9.2.56(438-124593566)的HTC One M8(Android 6.0软件编号6.12.401.4)的位置服务存在一般问题,而不仅仅是gps. Google Play服务FusedLocationApi存在权限系统问题,导致获得权限但会引发SecurityException.使用旧的LocationManager实现没有安全问题,但只能在设备设置仅设置为gps时确定位置.
Stacktrace:
Fatal Exception: java.lang.SecurityException: Client must have ACCESS_FINE_LOCATION permission to request PRIORITY_HIGH_ACCURACY locations. at android.os.Parcel.readException(Parcel.java:1620) at android.os.Parcel.readException(Parcel.java:1573) at com.google.android.gms.location.internal.zzi$zza$zza.zza(Unknown Source) at com.google.android.gms.location.internal.zzk.getLastLocation(Unknown Source) at com.google.android.gms.location.internal.zzl.getLastLocation(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.internal.zznt$zza.zzre(Unknown Source) at com.google.android.gms.internal.zzoc.connect(Unknown Source) at com.google.android.gms.internal.zzoc.zzd(Unknown Source) at com.google.android.gms.internal.zzoh.zzd(Unknown Source) at com.google.android.gms.internal.zzof.zzd(Unknown Source) at com.google.android.gms.location.internal.zzd.getLastLocation(Unknown Source) at com.my.package.location.PlayServicesLocationFinder.onConnected(PlayServicesLocationFinder.java:74) at com.google.android.gms.common.internal.zzl.zztI(Unknown Source) at com.google.android.gms.internal.zzof.zzc(Unknown Source) at com.google.android.gms.internal.zzod.zzsb(Unknown Source) at com.google.android.gms.internal.zzod.begin(Unknown Source) at com.google.android.gms.internal.zzoh.zzc(Unknown Source) at com.google.android.gms.internal.zznw.onConnected(Unknown Source) at com.google.android.gms.common.internal.zzk$1.onConnected(Unknown Source) at com.google.android.gms.common.internal.zzd$zzj.zzl(Unknown Source) at com.google.android.gms.common.internal.zzd$zza.zztp(Unknown Source) at com.google.android.gms.common.internal.zzd$zza.zztp(Unknown Source) at com.google.android.gms.common.internal.zzd$zze.zztr(Unknown Source) at com.google.android.gms.common.internal.zzd$zzd.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:5461) at java.lang.reflect.Method.invoke(Method.java) at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:726) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616)
解决方法
September 21,2016
Resolved Issues
- Client must have ACCESS_FINE_LOCATION permission to request PRIORITY_HIGH_ACCURACY locations. (Issue 07001)@H_301_43@