当我尝试在Android上启动谷歌地图时,应用程序被销毁

时间:2014-09-17 09:54:09

标签: android google-maps

我的Android应用程序出现问题。我想在设备上启动谷歌地图,我的应用程序被销毁,我抓住了异常。这是我的stacktrace

09-17 15:38:48.546: E/AndroidRuntime(1979): FATAL EXCEPTION: main
09-17 15:38:48.546: E/AndroidRuntime(1979): java.lang.RuntimeException: Unable to start activity ComponentInfo{ru.fosslabs.mobilestudent/ru.fosslabs.mobilestudent.LocationActivity}: android.view.InflateException: Binary XML file line #2: Error inflating class fragment
09-17 15:38:48.546: E/AndroidRuntime(1979):     at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2211)
09-17 15:38:48.546: E/AndroidRuntime(1979):     at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2261)
09-17 15:38:48.546: E/AndroidRuntime(1979):     at android.app.ActivityThread.access$600(ActivityThread.java:141)
09-17 15:38:48.546: E/AndroidRuntime(1979):     at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1256)
09-17 15:38:48.546: E/AndroidRuntime(1979):     at android.os.Handler.dispatchMessage(Handler.java:99)
09-17 15:38:48.546: E/AndroidRuntime(1979):     at android.os.Looper.loop(Looper.java:137)
09-17 15:38:48.546: E/AndroidRuntime(1979):     at android.app.ActivityThread.main(ActivityThread.java:5103)
09-17 15:38:48.546: E/AndroidRuntime(1979):     at java.lang.reflect.Method.invokeNative(Native Method)
09-17 15:38:48.546: E/AndroidRuntime(1979):     at java.lang.reflect.Method.invoke(Method.java:525)
09-17 15:38:48.546: E/AndroidRuntime(1979):     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:737)
09-17 15:38:48.546: E/AndroidRuntime(1979):     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:553)
09-17 15:38:48.546: E/AndroidRuntime(1979):     at dalvik.system.NativeStart.main(Native Method)
09-17 15:38:48.546: E/AndroidRuntime(1979): Caused by: android.view.InflateException: Binary XML file line #2: Error inflating class fragment
09-17 15:38:48.546: E/AndroidRuntime(1979):     at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:713)
09-17 15:38:48.546: E/AndroidRuntime(1979):     at android.view.LayoutInflater.inflate(LayoutInflater.java:469)
09-17 15:38:48.546: E/AndroidRuntime(1979):     at android.view.LayoutInflater.inflate(LayoutInflater.java:397)
09-17 15:38:48.546: E/AndroidRuntime(1979):     at android.view.LayoutInflater.inflate(LayoutInflater.java:353)
09-17 15:38:48.546: E/AndroidRuntime(1979):     at com.android.internal.policy.impl.PhoneWindow.setContentView(PhoneWindow.java:267)
09-17 15:38:48.546: E/AndroidRuntime(1979):     at android.app.Activity.setContentView(Activity.java:1895)
09-17 15:38:48.546: E/AndroidRuntime(1979):     at ru.fosslabs.mobilestudent.LocationActivity.onCreate(LocationActivity.java:28)
09-17 15:38:48.546: E/AndroidRuntime(1979):     at android.app.Activity.performCreate(Activity.java:5133)
09-17 15:38:48.546: E/AndroidRuntime(1979):     at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1087)
09-17 15:38:48.546: E/AndroidRuntime(1979):     at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2175)
09-17 15:38:48.546: E/AndroidRuntime(1979):     ... 11 more
09-17 15:38:48.546: E/AndroidRuntime(1979): Caused by: android.app.Fragment$InstantiationException: Unable to instantiate fragment com.google.android.gms.maps.MapFragment: make sure class name exists, is public, and has an empty constructor that is public
09-17 15:38:48.546: E/AndroidRuntime(1979):     at android.app.Fragment.instantiate(Fragment.java:592)
09-17 15:38:48.546: E/AndroidRuntime(1979):     at android.app.Fragment.instantiate(Fragment.java:560)
09-17 15:38:48.546: E/AndroidRuntime(1979):     at android.app.Activity.onCreateView(Activity.java:4738)
09-17 15:38:48.546: E/AndroidRuntime(1979):     at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:689)
09-17 15:38:48.546: E/AndroidRuntime(1979):     ... 20 more
09-17 15:38:48.546: E/AndroidRuntime(1979): Caused by: java.lang.ClassNotFoundException: Didn't find class "com.google.android.gms.maps.MapFragment" on path: DexPathList[[zip file "/data/app/ru.fosslabs.mobilestudent-1.apk"],nativeLibraryDirectories=[/data/app-lib/ru.fosslabs.mobilestudent-1, /system/lib]]
09-17 15:38:48.546: E/AndroidRuntime(1979):     at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:53)
09-17 15:38:48.546: E/AndroidRuntime(1979):     at java.lang.ClassLoader.loadClass(ClassLoader.java:501)
09-17 15:38:48.546: E/AndroidRuntime(1979):     at java.lang.ClassLoader.loadClass(ClassLoader.java:461)
09-17 15:38:48.546: E/AndroidRuntime(1979):     at android.app.Fragment.instantiate(Fragment.java:582)
09-17 15:38:48.546: E/AndroidRuntime(1979):     ... 23 more

1 个答案:

答案 0 :(得分:0)

您可能没有在项目中选择适当的Android API

请查看此屏幕并选择其中一个Google APIs以访问地图功能。

enter image description here