地图不起作用

时间:2012-08-14 15:32:09

标签: android google-maps

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

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

2 个答案:

答案 0 :(得分:3)

将此行添加到AndroidManifest.xml

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

答案 1 :(得分:1)

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

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

当您使用互联网和呼叫等内容时,您需要添加权限。