我正在尝试使用React Native在地图上绘制一条折线,但是只要我编译了我的应用程序,它将给我以下跟踪信息。
这是痕迹
`java.lang.SecurityException: Looks like the app doesn't have the permission to access location.`
`Add the following line to your app's AndroidManifest.xml:`
`<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
at` `com.facebook.react.modules.location.LocationModule.throwLocationPermissionMissing(LocationModule.java:235)
at ``com.facebook.react.modules.location.LocationModule.startObserving(LocationModule.java:174)`
`at java.lang.reflect.Method.invoke(Native Method)
at ``com.facebook.react.bridge.JavaMethodWrapper.invoke(JavaMethodWrapper.java:372)
at ``com.facebook.react.bridge.JavaModuleWrapper.invoke(JavaModuleWrapper.java:158)
at com.facebook.react.bridge.queue.NativeRunnable.run(Native Method)`
`at android.os.Handler.handleCallback(Handler.java:794)`
`at android.os.Handler.dispatchMessage(Handler.java:99)
at ``com.facebook.react.bridge.queue.MessageQueueThreadHandler.dispatchMessage(MessageQueueThreadHandler.java:29)`
`at android.os.Looper.loop(Looper.java:176)
at ``com.facebook.react.bridge.queue.MessageQueueThreadImpl$3.run(MessageQueueThreadImpl.java:192)`
`at java.lang.Thread.run(Thread.java:764)`
`Caused by: java.lang.SecurityException: "gps" location provider requires ACCESS_FINE_LOCATION permission.`
`at android.os.Parcel.readException(Parcel.java:2013)`
`at android.os.Parcel.readException(Parcel.java:1959)`
at ``android.location.ILocationManager$Stub$Proxy.requestLocationUpdates(ILocationManager.java:691)
at ``android.location.LocationManager.requestLocationUpdates(LocationManager.java:900)
at ``android.location.LocationManager.requestLocationUpdates(LocationManager.java:471)
at ``com.facebook.react.modules.location.LocationModule.startObserving(LocationModule.java:166)`
... 10 more
答案 0 :(得分:0)
添加AndroidManifest.xml
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
<application>
{...}
<meta-data
android:name="com.google.android.geo.API_KEY"
android:value="Add Your Google API" />
</application>