我正在尝试打开谷歌地图以显示一些位置。我正在关注此http://mobisys.in/blog/2012/12/google-rolls-out-android-maps-api-v2/链接,但它没有打开映射它的崩溃,并说膨胀异常二进制文件号#2,我已检入清单元数据很好,片段区分大小写,键是正确的,在这里它是我的堆栈跟踪:
02-26 18:15:25.648: I/System.out(5029): img button cust.>> 02-26
18:15:25.718: D/AndroidRuntime(5029): Shutting down VM 02-26
18:15:25.718: W/dalvikvm(5029): threadid=1: thread exiting with
uncaught exception (group=0x40a191f8) 02-26 18:15:25.758:
E/AndroidRuntime(5029): FATAL EXCEPTION: main 02-26 18:15:25.758:
E/AndroidRuntime(5029): java.lang.RuntimeException: Unable to start
activity
ComponentInfo{com.intertec.iforce/com.intertec.iforce.MapActivity}:
android.view.InflateException: Binary XML file line #2: Error
inflating class fragment 02-26 18:15:25.758: E/AndroidRuntime(5029):
at
android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1956)
02-26 18:15:25.758: E/AndroidRuntime(5029): at
android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1981)
02-26 18:15:25.758: E/AndroidRuntime(5029): at
android.app.ActivityThread.access$600(ActivityThread.java:123) 02-26
18:15:25.758: E/AndroidRuntime(5029): at
android.app.ActivityThread$H.handleMessage(ActivityThread.java:1147)
02-26 18:15:25.758: E/AndroidRuntime(5029): at
android.os.Handler.dispatchMessage(Handler.java:99) 02-26
18:15:25.758: E/AndroidRuntime(5029): at
android.os.Looper.loop(Looper.java:137) 02-26 18:15:25.758:
E/AndroidRuntime(5029): at
android.app.ActivityThread.main(ActivityThread.java:4424) 02-26
18:15:25.758: E/AndroidRuntime(5029): at
java.lang.reflect.Method.invokeNative(Native Method) 02-26
18:15:25.758: E/AndroidRuntime(5029): at
java.lang.reflect.Method.invoke(Method.java:511) 02-26 18:15:25.758:
E/AndroidRuntime(5029): at
com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:784)
02-26 18:15:25.758: E/AndroidRuntime(5029): at
com.android.internal.os.ZygoteInit.main(ZygoteInit.java:551) 02-26
18:15:25.758: E/AndroidRuntime(5029): at
dalvik.system.NativeStart.main(Native Method) 02-26 18:15:25.758:
E/AndroidRuntime(5029): Caused by: android.view.InflateException:
Binary XML file line #2: Error inflating class fragment 02-26
18:15:25.758: E/AndroidRuntime(5029): at
android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:697)
02-26 18:15:25.758: E/AndroidRuntime(5029): at
android.view.LayoutInflater.inflate(LayoutInflater.java:466) 02-26
18:15:25.758: E/AndroidRuntime(5029): at
android.view.LayoutInflater.inflate(LayoutInflater.java:396) 02-26
18:15:25.758: E/AndroidRuntime(5029): at
android.view.LayoutInflater.inflate(LayoutInflater.java:352) 02-26
18:15:25.758: E/AndroidRuntime(5029): at
com.android.internal.policy.impl.PhoneWindow.setContentView(PhoneWindow.java:251)
02-26 18:15:25.758: E/AndroidRuntime(5029): at
android.app.Activity.setContentView(Activity.java:1862) 02-26
18:15:25.758: E/AndroidRuntime(5029): at
com.intertec.iforce.MapActivity.onCreate(MapActivity.java:23) 02-26
18:15:25.758: E/AndroidRuntime(5029): at
android.app.Activity.performCreate(Activity.java:4492) 02-26
18:15:25.758: E/AndroidRuntime(5029): at
android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1049)
02-26 18:15:25.758: E/AndroidRuntime(5029): at
android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1920)
02-26 18:15:25.758: E/AndroidRuntime(5029): ... 11 more 02-26
18:15:25.758: E/AndroidRuntime(5029): Caused by:
android.support.v4.app.Fragment$InstantiationException: Unable to
instantiate fragment com.google.android.gms.maps.SupportMapFragment:
make sure class name exists, is public, and has an empty constructor
that is public 02-26 18:15:25.758: E/AndroidRuntime(5029): at
android.support.v4.app.Fragment.instantiate(Fragment.java:401) 02-26
18:15:25.758: E/AndroidRuntime(5029): at
android.support.v4.app.Fragment.instantiate(Fragment.java:369) 02-26
18:15:25.758: E/AndroidRuntime(5029): at
android.support.v4.app.FragmentActivity.onCreateView(FragmentActivity.java:272)
02-26 18:15:25.758: E/AndroidRuntime(5029): at
android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:669)
02-26 18:15:25.758: E/AndroidRuntime(5029): ... 20 more 02-26
18:15:25.758: E/AndroidRuntime(5029): Caused by:
java.lang.ClassNotFoundException:
com.google.android.gms.maps.SupportMapFragment 02-26 18:15:25.758:
E/AndroidRuntime(5029): at
dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:61)
02-26 18:15:25.758: E/AndroidRuntime(5029): at
java.lang.ClassLoader.loadClass(ClassLoader.java:501) 02-26
18:15:25.758: E/AndroidRuntime(5029): at
java.lang.ClassLoader.loadClass(ClassLoader.java:461) 02-26
18:15:25.758: E/AndroidRuntime(5029): at
android.support.v4.app.Fragment.instantiate(Fragment.java:391) 02-26
18:15:25.758: E/AndroidRuntime(5029): ... 23 more 02-26 18:15:25.838:
D/dalvikvm(5029): GC_CONCURRENT freed 326K, 20% free 6795K/8391K,
paused 2ms+2ms 02-26 18:20:25.808: I/Process(5029): Sending signal.
PID: 5029 SIG: 9
答案 0 :(得分:1)
您似乎错过了从\extras\google\google_play_services\libproject\google-play-services_lib
导入项目。
将其添加为library
到您当前的项目。
确保您已将SupportMapFragment
用于11下的API。
?xml version="1.0" encoding="utf-8"?>
<fragment xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/map"
android:name="com.google.android.gms.maps.SupportMapFragment"
android:layout_width="wrap_content"
android:layout_height="match_parent" />