1

.我有简单的地图应用程序。首先我的地图正在工作。然后我允许开发我的应用程序我强制关闭。当我运行我的应用程序时出现以下错误:

08-14 20:57:26.855: E/AndroidRuntime(207): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example.mapss/com.example.mapss.MainActivity}: java.lang.SecurityException: Requires ACCESS_FINE_LOCATION permission
08-14 20:57:26.855: E/AndroidRuntime(207):  at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2401)
08-14 20:57:26.855: E/AndroidRuntime(207):  at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2417)
08-14 20:57:26.855: E/AndroidRuntime(207):  at android.app.ActivityThread.access$2100(ActivityThread.java:116)
08-14 20:57:26.855: E/AndroidRuntime(207):  at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1794)
08-14 20:57:26.855: E/AndroidRuntime(207):  at android.os.Handler.dispatchMessage(Handler.java:99)
08-14 20:57:26.855: E/AndroidRuntime(207):  at android.os.Looper.loop(Looper.java:123)
08-14 20:57:26.855: E/AndroidRuntime(207):  at android.app.ActivityThread.main(ActivityThread.java:4203)
08-14 20:57:26.855: E/AndroidRuntime(207):  at java.lang.reflect.Method.invokeNative(Native Method)
08-14 20:57:26.855: E/AndroidRuntime(207):  at java.lang.reflect.Method.invoke(Method.java:521)
08-14 20:57:26.855: E/AndroidRuntime(207):  at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:791)
08-14 20:57:26.855: E/AndroidRuntime(207):  at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:549)
08-14 20:57:26.855: E/AndroidRuntime(207):  at dalvik.system.NativeStart.main(Native Method)
08-14 20:57:26.855: E/AndroidRuntime(207): Caused by: java.lang.SecurityException: Requires ACCESS_FINE_LOCATION permission
08-14 20:57:26.855: E/AndroidRuntime(207):  at android.os.Parcel.readException(Parcel.java:1218)
08-14 20:57:26.855: E/AndroidRuntime(207):  at android.os.Parcel.readException(Parcel.java:1206)
08-14 20:57:26.855: E/AndroidRuntime(207):  at android.location.ILocationManager$Stub$Proxy.getLastKnownLocation(ILocationManager.java:776)
08-14 20:57:26.855: E/AndroidRuntime(207):  at android.location.LocationManager.getLastKnownLocation(LocationManager.java:945)
08-14 20:57:26.855: E/AndroidRuntime(207):  at com.example.mapss.MainActivity.onCreate(MainActivity.java:36)
08-14 20:57:26.855: E/AndroidRuntime(207):  at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1123)
08-14 20:57:26.855: E/AndroidRuntime(207):  at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2364)
08-14 20:57:26.855: E/AndroidRuntime(207):  ... 11 more
4

2 回答 2

3

将此行添加到您的AndroidManifest.xml

 <uses-permission android:name="android.permission.ACCESS_FINE_LOCATION"/>
于 2012-08-14T15:37:47.877 回答
1

在使用Maps或其他类型的服务时,您需要确保为您的清单添加适当的权限,在这种情况下:

<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION"/>

当您使用互联网和通话等功能时,您需要添加权限。

于 2012-08-14T15:48:42.907 回答