Android GoogleMaps无法在某些设备上运行,显示java.lang.SecurityException:需要INSTALL_LOCATION_PROVIDER权限

时间:2017-07-28 07:12:41

标签: java android google-maps

我尝试使用GoogleMap制作地图应用程序以获取位置坐标和反向地理编码。我试图在联想A7000plus中运行它,它运行正常没有任何问题。

不知何故,我用相同的Android Marshmallow测试我的应用程序到一些小米,地图根本不工作。只有这样的错误报告:

07-28 14:04:01.144 19465-19465/? E/NetworkLocationProvider: Exception
                                                            java.lang.SecurityException: need INSTALL_LOCATION_PROVIDER permission, or UID of a currently bound location provider
                                                                at android.os.Parcel.readException(Parcel.java:1620)
                                                                at android.os.Parcel.readException(Parcel.java:1573)
                                                                at android.location.ILocationManager$Stub$Proxy.reportLocation(ILocationManager.java:1281)
                                                                at com.android.location.provider.LocationProviderBase.reportLocation(LocationProviderBase.java:136)
                                                                at com.amap.android.location.v.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:5441)
                                                                at java.lang.reflect.Method.invoke(Native Method)
                                                                at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:738)
                                                                at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:628)
07-28 14:04:01.164 19465-19465/? E/NetworkLocationProvider: Exception
                                                            java.lang.SecurityException: need INSTALL_LOCATION_PROVIDER permission, or UID of a currently bound location provider
                                                                at android.os.Parcel.readException(Parcel.java:1620)
                                                                at android.os.Parcel.readException(Parcel.java:1573)
                                                                at android.location.ILocationManager$Stub$Proxy.reportLocation(ILocationManager.java:1281)
                                                                at com.android.location.provider.LocationProviderBase.reportLocation(LocationProviderBase.java:136)
                                                                at com.amap.android.location.v.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:5441)
                                                                at java.lang.reflect.Method.invoke(Native Method)
                                                                at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:738)
                                                                at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:628)

此外,这是我实施的Manifest

<uses-sdk android:minSdkVersion="14" />

<permission
    android:name="com.myapps.permission.MAPS_RECEIVE"
    android:protectionLevel="signature" />

<uses-permission android:name="com.myapps.permission.MAPS_RECEIVE" />
<uses-permission android:name="com.google.android.providers.gsf.permission.READ_GSERVICES" />
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.CAMERA" />
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.READ_PHONE_STATE" />
<uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED" />
<uses-permission android:name="android.permission.WAKE_LOCK" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />

<uses-feature android:name="android.hardware.camera" />
<uses-feature android:name="android.hardware.camera.autofocus" />
<uses-feature
    android:glEsVersion="0x00020000"
    android:required="true" />

你能帮我解决一下这个问题吗?

**编辑:**我已将运行时权限放在我的代码上,因为我使用的所有手机包括联想A7000都是Marshmallow。但不知何故,它不适用于相同版本的Android的小米手机

3 个答案:

答案 0 :(得分:1)

您必须询问运行时权限才能访问位置数据。自Android 6.0发布以来,用户在运行时向应用程序授予权限。这个link解释了运行时权限。

答案 1 :(得分:1)

从API 23开始,您需要在运行时请求危险权限检查此链接如何在运行时https://developer.android.com/training/permissions/requesting.html或build.gradle文件中请求危险将目标SDK级别更改为22

答案 2 :(得分:0)

根据文档,INSTALL_LOCATION_PROVIDER

  

不适用于第三方应用程序。