版本的Android M谷歌API的使用谷歌地图和其他权限 [英] Android M Google API's to use Google Maps and other permissions
问题描述
我有版本的Android M设置为我的项目,并可以建立很好。然而,当我启动应用程序,我看到下面的错误和应用程序无法启动:
<十一月6日至23日:53:24.833 32416 32416W¯¯System.err的:了java.lang.RuntimeException:**无法创建应用程序XXXXX:java.lang.SecurityException异常: GPS定位提供商要求ACCESS_FINE_LOCATION许可。**
11月6日至23日:53:24.833 32416 32416W¯¯System.err的:在android.app.ActivityThread.handleBindApplication(ActivityThread.java:4697)
11月6日至23日:53:24.833 32416 32416W¯¯System.err的:在android.app.ActivityThread.-wrap1(ActivityThread.java)
11月6日至23日:53:24.833 32416 32416W¯¯System.err的:在android.app.ActivityThread $ H.handleMessage(ActivityThread.java:1404)
11月6日至23日:53:24.833 32416 32416W¯¯System.err的:在android.os.Handler.dispatchMessage(Handler.java:102)
11月6日至23日:53:24.833 32416 32416W¯¯System.err的:在android.os.Looper.loop(Looper.java:148)
11月6日至23日:53:24.833 32416 32416W¯¯System.err的:在android.app.ActivityThread.main(ActivityThread.java:5401)
11月6日至23日:53:24.833 32416 32416W¯¯System.err的:在java.lang.reflect.Method.invoke(本机方法)
11月6日至23日:53:24.833 32416 32416W¯¯System.err的:在com.android.internal.os.ZygoteInit $ MethodAndArgsCaller.run(ZygoteInit.java:725)
11月6日至23日:53:24.833 32416 32416W¯¯System.err的:在com.android.internal.os.ZygoteInit.main(ZygoteInit.java:615)
11月6日至23日:53:24.833 32416 32416W¯¯System.err的:产生的原因:** java.lang.SecurityException异常:GPS定位提供商要求ACCESS_FINE_LOCATION许可**。
11月6日至23日:53:24.833 32416 32416W¯¯System.err的:在android.os.Parcel.readException(Parcel.java:1599)
11月6日至23日:53:24.833 32416 32416W¯¯System.err的:在android.os.Parcel.readException(Parcel.java:1552)
11月6日至23日:53:24.833 32416 32416W¯¯System.err的:在android.location.ILocationManager $存根$ Proxy.requestLocationUpdates(ILocationManager.java:598)
11月6日至23日:53:24.834 32416 32416W¯¯System.err的:在android.location.LocationManager.requestLocationUpdates(LocationManager.java:880)
11月6日至23日:53:24.834 32416 32416W¯¯System.err的:在android.location.LocationManager.requestLocationUpdates(LocationManager.java:464)
我已经提供了所有这些权限ACCESS_FINE_LOCATION,network_state,互联网和ACCESS_COARSE_LOCATION在我的清单文件作为PROTECTED_NORMAL,使他们可在安装时。
我也注意到,谷歌的API从版本的Android M preVIEW失踪,可能这就是导致问题?虽然不能肯定。想知道是否有人在同样的问题,一个可能的解决方案来的?
清单文件的一部分:
<采用-SDK
安卓的minSdkVersion =MNC
机器人:targetSdkVersion =MNC/> <许可
机器人:名字=android.permission.ACCESS_NETWORK_STATE
安卓的ProtectionLevel =正常/> <许可
机器人:名字=android.permission.ACCESS_FINE_LOCATION
安卓的ProtectionLevel =正常/> <许可
机器人:名字=android.permission.ACCESS_COARSE_LOCATION
安卓的ProtectionLevel =正常/> <许可
机器人:名字=android.permission.INTERNET对
安卓的ProtectionLevel =正常/><使用许可权的android:NAME =android.permission.ACCESS_NETWORK_STATE/>
<使用许可权的android:NAME =android.permission.ACCESS_FINE_LOCATION/>
<使用许可权的android:NAME =android.permission.ACCESS_COARSE_LOCATION/>
<使用许可权的android:NAME =android.permission.INTERNET对/><应用>
<使用库机器人:名字=com.google.android.maps/>
**活动的声明**
< /用途>
谢谢!
我已经提供了所有这些权限ACCESS_FINE_LOCATION,network_state,互联网和ACCESS_COARSE_LOCATION在我的清单文件作为PROTECTED_NORMAL,使他们可在安装时。
块引用>没有。这些权限由平台定义的,而不是你。你不能重新定义它们具有更低的保护级别,而
位置
权限危险
。而且,正如的M开发preVIEW文档状态,这些都是你需要在运行时要求的权限。
一个可能的解决方案?
块引用>请求来自用户的位置权限试图使用地图之前。请注意,我没有尝试过的M开发preVIEW地图还,所以它可能是,这是不是在所有现在支持。
I have Android M set up for my project and could build fine. However, When i launch the app, i see the following error and app doesn't launch:
<06-23 11:53:24.833 32416 32416 W System.err: java.lang.RuntimeException: **Unable to create application xxxxx: java.lang.SecurityException: "gps" location provider requires ACCESS_FINE_LOCATION permission.** 06-23 11:53:24.833 32416 32416 W System.err: at android.app.ActivityThread.handleBindApplication(ActivityThread.java:4697) 06-23 11:53:24.833 32416 32416 W System.err: at android.app.ActivityThread.-wrap1(ActivityThread.java) 06-23 11:53:24.833 32416 32416 W System.err: at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1404) 06-23 11:53:24.833 32416 32416 W System.err: at android.os.Handler.dispatchMessage(Handler.java:102) 06-23 11:53:24.833 32416 32416 W System.err: at android.os.Looper.loop(Looper.java:148) 06-23 11:53:24.833 32416 32416 W System.err: at android.app.ActivityThread.main(ActivityThread.java:5401) 06-23 11:53:24.833 32416 32416 W System.err: at java.lang.reflect.Method.invoke(Native Method) 06-23 11:53:24.833 32416 32416 W System.err: at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:725) 06-23 11:53:24.833 32416 32416 W System.err: at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:615) 06-23 11:53:24.833 32416 32416 W System.err: Caused by: **java.lang.SecurityException: "gps" location provider requires ACCESS_FINE_LOCATION permission**. 06-23 11:53:24.833 32416 32416 W System.err: at android.os.Parcel.readException(Parcel.java:1599) 06-23 11:53:24.833 32416 32416 W System.err: at android.os.Parcel.readException(Parcel.java:1552) 06-23 11:53:24.833 32416 32416 W System.err: at android.location.ILocationManager$Stub$Proxy.requestLocationUpdates(ILocationManager.java:598) 06-23 11:53:24.834 32416 32416 W System.err: at android.location.LocationManager.requestLocationUpdates(LocationManager.java:880) 06-23 11:53:24.834 32416 32416 W System.err: at android.location.LocationManager.requestLocationUpdates(LocationManager.java:464)
I have provided all these permissions access_fine_location, network_state, internet and access_coarse_location in my manifest file as "PROTECTED_NORMAL" So that they are available at install time.
I also noticed that Google API's were missing from Android M preview and may be thats causing the issue?? not sure though. Wondering if anyone came across the same issue and a possible solution?
part of manifest file:
<uses-sdk android:minSdkVersion ="MNC" android:targetSdkVersion ="MNC" /> <permission android:name="android.permission.ACCESS_NETWORK_STATE" android:protectionLevel="normal" /> <permission android:name="android.permission.ACCESS_FINE_LOCATION" android:protectionLevel="normal" /> <permission android:name="android.permission.ACCESS_COARSE_LOCATION" android:protectionLevel="normal" /> <permission android:name="android.permission.INTERNET" android:protectionLevel="normal" /> <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" /> <uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" /> <uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" /> <uses-permission android:name="android.permission.INTERNET" /> <application> <uses-library android:name="com.google.android.maps" /> **activity declarations** </application>
Thanks!!
解决方案I have provided all these permissions access_fine_location, network_state, internet and access_coarse_location in my manifest file as "PROTECTED_NORMAL" So that they are available at install time.
No. Those permissions are defined by the platform, not you. You cannot redefine them to have lower protection levels, and the
LOCATION
permissions aredangerous
. And, as the M Developer Preview documentation states, those are permissions that you need to request at runtime.a possible solution?
Request the location permissions from the user before attempting to use the map. Note that I have not tried maps on the M Developer Preview yet, so it may be that this is not supported at all right now.
这篇关于版本的Android M谷歌API的使用谷歌地图和其他权限的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!