错误充气类片段的Andr​​oid地图V2 [英] Error inflating class fragment Android Map v2

查看:183
本文介绍了错误充气类片段的Andr​​oid地图V2的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我知道这是一个重复的问题,但是从previous后的解决方案不工作
  我。这就是为什么要问这个问题。

I know this is a duplicate question, but solutions from previous post doesn't worked for me. Thats why am asking this question.

我想实现谷歌地图V2在Android应用程序,我得到了以下错误

I am trying to implement Google Map V2 in Android App, I got below error

06-26 19:24:51.035: E/AndroidRuntime(7679): FATAL EXCEPTION: main
06-26 19:24:51.035: E/AndroidRuntime(7679): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.titutorial.mapdemo/com.titutorial.mapdemo.MainActivity}: android.view.InflateException: Binary XML file line #2: Error inflating class fragment
06-26 19:24:51.035: E/AndroidRuntime(7679):     at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2100)
06-26 19:24:51.035: E/AndroidRuntime(7679):     at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2125)
06-26 19:24:51.035: E/AndroidRuntime(7679):     at android.app.ActivityThread.access$600(ActivityThread.java:140)
06-26 19:24:51.035: E/AndroidRuntime(7679):     at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1227)
06-26 19:24:51.035: E/AndroidRuntime(7679):     at android.os.Handler.dispatchMessage(Handler.java:99)
06-26 19:24:51.035: E/AndroidRuntime(7679):     at android.os.Looper.loop(Looper.java:137)
06-26 19:24:51.035: E/AndroidRuntime(7679):     at android.app.ActivityThread.main(ActivityThread.java:4898)
06-26 19:24:51.035: E/AndroidRuntime(7679):     at java.lang.reflect.Method.invokeNative(Native Method)
06-26 19:24:51.035: E/AndroidRuntime(7679):     at java.lang.reflect.Method.invoke(Method.java:511)
06-26 19:24:51.035: E/AndroidRuntime(7679):     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1006)
06-26 19:24:51.035: E/AndroidRuntime(7679):     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:773)
06-26 19:24:51.035: E/AndroidRuntime(7679):     at dalvik.system.NativeStart.main(Native Method)
06-26 19:24:51.035: E/AndroidRuntime(7679): Caused by: android.view.InflateException: Binary XML file line #2: Error inflating class fragment
06-26 19:24:51.035: E/AndroidRuntime(7679):     at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:704)
06-26 19:24:51.035: E/AndroidRuntime(7679):     at android.view.LayoutInflater.inflate(LayoutInflater.java:466)
06-26 19:24:51.035: E/AndroidRuntime(7679):     at android.view.LayoutInflater.inflate(LayoutInflater.java:396)
06-26 19:24:51.035: E/AndroidRuntime(7679):     at android.view.LayoutInflater.inflate(LayoutInflater.java:352)
06-26 19:24:51.035: E/AndroidRuntime(7679):     at com.android.internal.policy.impl.PhoneWindow.setContentView(PhoneWindow.java:308)
06-26 19:24:51.035: E/AndroidRuntime(7679):     at android.app.Activity.setContentView(Activity.java:1924)
06-26 19:24:51.035: E/AndroidRuntime(7679):     at com.titutorial.mapdemo.MainActivity.onCreate(MainActivity.java:12)
06-26 19:24:51.035: E/AndroidRuntime(7679):     at android.app.Activity.performCreate(Activity.java:5206)
06-26 19:24:51.035: E/AndroidRuntime(7679):     at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1083)
06-26 19:24:51.035: E/AndroidRuntime(7679):     at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2064)
06-26 19:24:51.035: E/AndroidRuntime(7679):     ... 11 more
06-26 19:24:51.035: E/AndroidRuntime(7679): 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
06-26 19:24:51.035: E/AndroidRuntime(7679):     at android.app.Fragment.instantiate(Fragment.java:584)
06-26 19:24:51.035: E/AndroidRuntime(7679):     at android.app.Fragment.instantiate(Fragment.java:552)
06-26 19:24:51.035: E/AndroidRuntime(7679):     at android.app.Activity.onCreateView(Activity.java:4849)
06-26 19:24:51.035: E/AndroidRuntime(7679):     at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:680)
06-26 19:24:51.035: E/AndroidRuntime(7679):     ... 20 more
06-26 19:24:51.035: E/AndroidRuntime(7679): Caused by: java.lang.ClassNotFoundException: com.google.android.gms.maps.MapFragment
06-26 19:24:51.035: E/AndroidRuntime(7679):     at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:61)
06-26 19:24:51.035: E/AndroidRuntime(7679):     at java.lang.ClassLoader.loadClass(ClassLoader.java:501)
06-26 19:24:51.035: E/AndroidRuntime(7679):     at java.lang.ClassLoader.loadClass(ClassLoader.java:461)
06-26 19:24:51.035: E/AndroidRuntime(7679):     at android.app.Fragment.instantiate(Fragment.java:574)
06-26 19:24:51.035: E/AndroidRuntime(7679):     ... 23 more

我也跟着下面的教程,

I followed below tutorial,

<一个href=\"https://developers.google.com/maps/documentation/android/start#installing_the_google_maps_android_v2_api\" rel=\"nofollow\">https://developers.google.com/maps/documentation/android/start#installing_the_google_maps_android_v2_api

我做的事情如下


  1. 安装谷歌播放服务

  2. 创建于谷歌控制台一个新的应用,并得到了谷歌地图API密钥

  3. 创建新的应用程序在Eclipse和在AndroidManifest.xml中添加的权限和谷歌地图API密钥

  4. 添加谷歌Play服务库到App

  5. 添加映射到应用(main.xml中)

  6. 设置有针对性的API级别17

在我的main.xml

in my main.xml

<?xml version="1.0" encoding="utf-8"?>
<fragment xmlns:android="http://schemas.android.com/apk/res/android"
          android:id="@+id/map"
          android:layout_width="match_parent"
          android:layout_height="match_parent"
          android:name="com.google.android.gms.maps.MapFragment"/>

这是我的完整的源$ C ​​$ C
https://github.com/railskarthi/MapDemo

推荐答案

API 11+之后,我觉得你现在必须更换 MapFragment SupportMapFragment 。这将是这样的:

After API 11+, I think you now have have to replace your MapFragment by SupportMapFragment. It would be something like:

<fragment xmlns:android="http://schemas.android.com/apk/res/android"
 android:id="@+id/map"
 android:layout_width="match_parent"
 android:layout_height="match_parent"
 android:name="com.google.android.gms.maps.SupportMapFragment"/>

这里更多信息,请看。让我知道你跟去。

Take a look here for further information. Let me know how are you going with.

这篇关于错误充气类片段的Andr​​oid地图V2的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆