谷歌地图V2 - 错误充气类片段 [英] Google Maps V2 - Error inflating class Fragment

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

问题描述

我想我的手,Android应用开发。我目前使用的Eclipse(我不记得的版本,无论是最新的)。我穿过一座桥时,我似乎无法掌握我在做什么错。我尝试使用谷歌地图API V2。我经历过几个文件,并尝试了几种方法,所有这些都导致了同样的错误:

I'm trying my hand and Android Application Development. I'm currently using Eclipse (I can't remember the version, whatever the newest is). I've crossed a bridge where I just can't seem to grasp what I'm doing wrong. I'm attempting to use the Google Maps V2 API. I've been through several documents and tried several techniques, all of which lead to the same error:

Android.view.Inflate Exception: Binary XML file line #2: Error inflating class fragment

我一直在敲打我的脸变成2天键直试图抓住什么,我做错了。

I've been pounding my face into the keys for 2 days straight trying to grasp what I'm doing wrong here.

东西:

  1. 在开始一个空白的活动。
  2. 项目 - >属性 - > Android的 - >的项目建设目标是谷歌的API - 4.2 - API 17 的 - 我已经试过的每次的其他选项,以及(只要如上3.0版本,发现里面记载
  3. 添加了谷歌播放的,services_lib我的包资源管理器。我指出,谷歌的播放,services_lib确实
  4. 项目 - >属性 - > Android的 - >库 - >添加 - >我选择的位置,以谷歌的播放,services_lib
  5. 包括 Android的支持 - v4.jar 作为我的项目的依赖关系。
  1. Started with a blank activity.
  2. Project -> Properties -> Android -> Project Build Target is Google APIs - 4.2 - API 17 - I've tried every other option as well (as long as above version 3.0, found it documented
  3. Added the google-play-services_lib to my Package Explorer. I indicated that the google-play-services_lib was indeed a library.
  4. Project -> Properties -> Android -> Library -> Add -> and I choose the location to the google-play-services_lib.
  5. Included android-support-v4.jar as a dependency of my project.

我试图从我相似的问题这么多不同的答案,但无济于事。 :( 我通常可以计算这些东西,但也许我只是太繁忙。

I've tried so many different answers from questions similar to mine, but to no avail. :( I can usually figure these things out, but maybe I'm just too overloaded.

在Eclipse中我的包浏览器树看起来像

My package explorer tree in eclipse looks like

  1. 在谷歌播放services_lib
  2. Svma

这里的code:>

activity_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"
    class="com.google.android.gms.maps.SupportMapFragment"/>

清单

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="com.testing.svma"
    android:versionCode="1"
    android:versionName="1.0" >

    <uses-sdk
        android:minSdkVersion="17"
        android:targetSdkVersion="17" />

    <permission
        android:name="com.testing.svma.permission.MAPS_RECEIVE"
        android:protectionLevel="signature" />

    <uses-permission android:name="com.testing.svma.permission.MAPS_RECEIVE" />
    <uses-permission android:name="android.permission.INTERNET" />
    <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
    <uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
    <uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
    <uses-permission android:name="com.google.android.providers.gsf.permission.READ_GSERVICES" />

    <application
        android:allowBackup="true"
        android:icon="@drawable/ic_launcher"
        android:label="@string/app_name"
        android:theme="@style/AppTheme" >
        <activity
            android:name="com.testing.svma.MainActivity"
            android:label="@string/app_name" >
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />

                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>

        <meta-data
            android:name="com.google.android.maps.v2.API_KEY"
            android:value="SHA1_Generated_KEY_HERE" />
    </application>

    <uses-feature
        android:glEsVersion="0x00020000"
        android:required="true" />
</manifest>

MainActivity.java

package com.testing.svma;

import android.os.Bundle;
import android.support.v4.app.FragmentActivity;

public class MainActivity extends FragmentActivity {

    @Override
    protected void onCreate(Bundle savedInstanceState) {

        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);


    }
}

参考文献

  1. 我用<一个href="http://stackoverflow.com/questions/14082851/error-inflating-class-fragment-with-google-map">Error充气类片段与谷歌地图,试图解决我的问题。

  1. I used "Error inflating class fragment" with google map to try and fix my issues.

我引用此谷歌地图快速入门指南创建我的项目

我已经开始初步具备样品code从引进到谷歌地图的Andr​​oid V2 API

所以问题整体转换。

那么,这样的社区,我究竟做错了什么?为什么我无法掌握这个简单的概念。

So, SO Community, what am I doing wrong? Why am I unable to grasp this simple concept.

感谢你在前进。

推荐答案

我有同样的code /同样的问题!尝试添加机器人:名称=com.testing.svma.MainActivity在布局碎片!它解决了这个问题对我来说

I have the same code/same problem! Try adding android:name="com.testing.svma.MainActivity" to "fragment" in the layout! It solved the issue for me

<?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"
    class="com.google.android.gms.maps.SupportMapFragment"
    android:name="com.testing.svma.MainActivity"/>

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

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