我试图在我的设备上显示地图(Android)。我认为我已经做了一切正确的事情以及添加了Manifest的权限,但是当执行它时说应用程序已经意外停止了。请再试一次。
清单文件详情
<uses-permission android:name="android.permission.INTERNET"/>
<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-feature android:glEsVersion="0x00020000" android:required="true"/>
<permission android:name="com.maps.permission.MAPS_RECEIVE" android:protectionLevel="signature"/>
<uses-permission android:name="com.maps.permission.MAPS_RECEIVE"/>
<meta-data android:name="com.google.android.maps.v2.API_KEY" android:value="AIzaSyD5oEA4Ct8_q_Ic-YBVjSv0_ANMfatvysY"/>
logcat的
05-16 20:19:43.433: W/dalvikvm(303): VFY: unable to resolve static field 872 (MapAttrs) in Lcom/google/android/gms/R$styleable;
05-16 20:19:43.433: D/dalvikvm(303): VFY: replacing opcode 0x62 at 0x000e
05-16 20:19:43.442: D/dalvikvm(303): VFY: dead code 0x0010-00ae in Lcom/google/android/gms/maps/GoogleMapOptions;.createFromAttributes (Landroid/content/Context;Landroid/util/AttributeSet;)Lcom/google/android/gms/maps/GoogleMapOptions;
05-16 20:19:43.452: D/AndroidRuntime(303): Shutting down VM
05-16 20:19:43.452: W/dalvikvm(303): threadid=1: thread exiting with uncaught exception (group=0x4001d800)
05-16 20:19:43.482: E/AndroidRuntime(303): FATAL EXCEPTION: main
05-16 20:19:43.482: E/AndroidRuntime(303): java.lang.NoClassDefFoundError: com.google.android.gms.R$styleable
05-16 20:19:43.482: E/AndroidRuntime(303): at com.google.android.gms.maps.GoogleMapOptions.createFromAttributes(Unknown Source)
05-16 20:19:43.482: E/AndroidRuntime(303): at com.google.android.gms.maps.SupportMapFragment.onInflate(Unknown Source)
05-16 20:19:43.482: E/AndroidRuntime(303): at android.support.v4.app.FragmentActivity.onCreateView(FragmentActivity.java:279)
05-16 20:19:43.482: E/AndroidRuntime(303): at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:558)
05-16 20:19:43.482: E/AndroidRuntime(303): at android.view.LayoutInflater.rInflate(LayoutInflater.java:618)
05-16 20:19:43.482: E/AndroidRuntime(303): at android.view.LayoutInflater.inflate(LayoutInflater.java:407)
05-16 20:19:43.482: E/AndroidRuntime(303): at android.view.LayoutInflater.inflate(LayoutInflater.java:320)
05-16 20:19:43.482: E/AndroidRuntime(303): at android.view.LayoutInflater.inflate(LayoutInflater.java:276)
05-16 20:19:43.482: E/AndroidRuntime(303): at com.android.internal.policy.impl.PhoneWindow.setContentView(PhoneWindow.java:198)
05-16 20:19:43.482: E/AndroidRuntime(303): at android.app.Activity.setContentView(Activity.java:1647)
05-16 20:19:43.482: E/AndroidRuntime(303): at com.example.mymap.Map.onCreate(Map.java:21)
05-16 20:19:43.482: E/AndroidRuntime(303): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1047)
05-16 20:19:43.482: E/AndroidRuntime(303): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2627)
05-16 20:19:43.482: E/AndroidRuntime(303): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2679)
05-16 20:19:43.482: E/AndroidRuntime(303): at android.app.ActivityThread.access$2300(ActivityThread.java:125)
05-16 20:19:43.482: E/AndroidRuntime(303): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2033)
05-16 20:19:43.482: E/AndroidRuntime(303): at android.os.Handler.dispatchMessage(Handler.java:99)
05-16 20:19:43.482: E/AndroidRuntime(303): at android.os.Looper.loop(Looper.java:123)
05-16 20:19:43.482: E/AndroidRuntime(303): at android.app.ActivityThread.main(ActivityThread.java:4627)
05-16 20:19:43.482: E/AndroidRuntime(303): at java.lang.reflect.Method.invokeNative(Native Method)
05-16 20:19:43.482: E/AndroidRuntime(303): at java.lang.reflect.Method.invoke(Method.java:521)
05-16 20:19:43.482: E/AndroidRuntime(303): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:868)
05-16 20:19:43.482: E/AndroidRuntime(303): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:626)
05-16 20:19:43.482: E/AndroidRuntime(303): at dalvik.system.NativeStart.main(Native Method)
05-16 20:24:43.612: I/Process(303): Sending signal. PID: 303 SIG: 9
答案 0 :(得分:1)
您应该在地图项目中引用Google Play服务库项目。
我猜您没有在Android地图项目中引用Google Play服务库
将您的图书馆项目导入您的工作场所。将其导入eclipse。
将库导入eclipse时。你可以,如果它是一个图书馆项目
右键单击您的图书馆项目。转到属性。选择android。你应该看到一个类似的窗口
右键单击您的项目。转到属性。选择android。点击添加。浏览并添加库项目。