0

我是 Google Maps V2 认证地图实施的新手,

但我根据https://developers.google.com/maps/documentation/android/start中的步骤进行了集成,但我遇到了崩溃。

它显示片刻白屏并崩溃,logcat

06-01 04:07:03.459: E/AndroidRuntime(1199): FATAL EXCEPTION: main
06-01 04:07:03.459: E/AndroidRuntime(1199): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.sample.map_test/com.sample.map_test.MainActivity}: android.view.InflateException: Binary XML file line #1: Error inflating class fragment
06-01 04:07:03.459: E/AndroidRuntime(1199): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1651)
06-01 04:07:03.459: E/AndroidRuntime(1199): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1667)
06-01 04:07:03.459: E/AndroidRuntime(1199): at android.app.ActivityThread.access$1500(ActivityThread.java:117)
06-01 04:07:03.459: E/AndroidRuntime(1199): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:935)
06-01 04:07:03.459: E/AndroidRuntime(1199): at android.os.Handler.dispatchMessage(Handler.java:99)
06-01 04:07:03.459: E/AndroidRuntime(1199): at android.os.Looper.loop(Looper.java:130)
06-01 04:07:03.459: E/AndroidRuntime(1199): at android.app.ActivityThread.main(ActivityThread.java:3687)
06-01 04:07:03.459: E/AndroidRuntime(1199): at java.lang.reflect.Method.invokeNative(Native Method)
06-01 04:07:03.459: E/AndroidRuntime(1199): at java.lang.reflect.Method.invoke(Method.java:507)
06-01 04:07:03.459: E/AndroidRuntime(1199): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:867)
06-01 04:07:03.459: E/AndroidRuntime(1199): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:625)
06-01 04:07:03.459: E/AndroidRuntime(1199): at dalvik.system.NativeStart.main(Native Method)
06-01 04:07:03.459: E/AndroidRuntime(1199): Caused by: android.view.InflateException: Binary XML file line #1: Error inflating class fragment
06-01 04:07:03.459: E/AndroidRuntime(1199): at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:587)
06-01 04:07:03.459: E/AndroidRuntime(1199): at android.view.LayoutInflater.inflate(LayoutInflater.java:386)
06-01 04:07:03.459: E/AndroidRuntime(1199): at android.view.LayoutInflater.inflate(LayoutInflater.java:320)
06-01 04:07:03.459: E/AndroidRuntime(1199): at android.view.LayoutInflater.inflate(LayoutInflater.java:276)
06-01 04:07:03.459: E/AndroidRuntime(1199): at com.android.internal.policy.impl.PhoneWindow.setContentView(PhoneWindow.java:209)
06-01 04:07:03.459: E/AndroidRuntime(1199): at android.app.Activity.setContentView(Activity.java:1657)
06-01 04:07:03.459: E/AndroidRuntime(1199): at com.sample.map_test.MainActivity.onCreate(MainActivity.java:12)
06-01 04:07:03.459: E/AndroidRuntime(1199): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1047)
06-01 04:07:03.459: E/AndroidRuntime(1199): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1615)
06-01 04:07:03.459: E/AndroidRuntime(1199): ... 11 more
06-01 04:07:03.459: E/AndroidRuntime(1199): Caused by: android.support.v4.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
06-01 04:07:03.459: E/AndroidRuntime(1199): at android.support.v4.app.Fragment.instantiate(Fragment.java:401)
06-01 04:07:03.459: E/AndroidRuntime(1199): at android.support.v4.app.Fragment.instantiate(Fragment.java:369)
06-01 04:07:03.459: E/AndroidRuntime(1199): at android.support.v4.app.FragmentActivity.onCreateView(FragmentActivity.java:272)
06-01 04:07:03.459: E/AndroidRuntime(1199): at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:563)
06-01 04:07:03.459: E/AndroidRuntime(1199): ... 19 more
06-01 04:07:03.459: E/AndroidRuntime(1199): Caused by: java.lang.ClassNotFoundException: com.google.android.gms.maps.MapFragment in loader dalvik.system.PathClassLoader[/data/app/com.sample.map_test-1.apk]
06-01 04:07:03.459: E/AndroidRuntime(1199): at dalvik.system.PathClassLoader.findClass(PathClassLoader.java:240)
06-01 04:07:03.459: E/AndroidRuntime(1199): at java.lang.ClassLoader.loadClass(ClassLoader.java:551)
06-01 04:07:03.459: E/AndroidRuntime(1199): at java.lang.ClassLoader.loadClass(ClassLoader.java:511)
06-01 04:07:03.459: E/AndroidRuntime(1199): at android.support.v4.app.Fragment.instantiate(Fragment.java:391)
06-01 04:07:03.459: E/AndroidRuntime(1199): ... 22 more

当我检查包含的库文件google-play-services_lib时,它显示为红色十字符号。我删除并再次添加它,添加时显示绿色刻度线,一旦我保存并关闭它就会变成红十字。

为什么我不能添加这个库项目?请建议我哪里出错了。

供您参考,只是为了测试我尝试了以下操作,我也尝试过处理google-play-services_lib项目库 jar 文件并粘贴到我的项目库文件夹中,但我仍然遇到同样的崩溃。

欢迎任何相关答案。提前致谢 。

4

1 回答 1

0

您不应该将 jar 复制到 libs 文件夹中。您应该在您的 android 项目中引用库项目。

将库项目导入工作区到eclipse中。图书馆项目可以在

   <android-sdk-folder>/extras/google/google_play_services/libproject/google-play-services_lib library project .

点击 File > Import,选择 Android > Existing Android Code into Workspace,浏览工作区导入库项目。您可以检查它是否是库项目。右键单击库项目。转到属性。单击左侧面板上的 Android。您将看到 Is Library 已选中。

右键单击您的项目。转到属性。选择安卓。单击添加。浏览并添加库项目。清洁和建造

在此处输入图像描述

于 2013-06-01T04:47:41.773 回答