二进制XML文件行#2:错误充气类 [英] Binary XML file line #2: Error inflating class

查看:270
本文介绍了二进制XML文件行#2:错误充气类的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我知道类似的问题,如这已经回答了,但我似乎做了什么教程建议,并从其他职位读,但我仍然得到充气错误。不知道我做错了。我没有看到谷歌地图。请检查code。非常感谢。

我产生我与重点:

 的keytool -list -v -keystore mystore.keystore

Activity_Map.java

 包pt.example.project;进口android.os.Bundle;
进口android.support.v4.app.FragmentActivity;公共类Activity_Map扩展FragmentActivity {    @覆盖
    保护无效的onCreate(捆绑savedInstanceState){
        super.onCreate(savedInstanceState);
        的setContentView(R.layout.filexml);
    }
}

filexml.xml

 <?XML版本=1.0编码=UTF-8&GT?;
<片段的xmlns:机器人=htt​​p://schemas.android.com/apk/res/android
      机器人:ID =@ + ID /图
      机器人:layout_width =match_parent
      机器人:layout_height =match_parent
      机器人:名字=com.google.android.gms.maps.MapFragment/>

AndroidManifest.xml中

 <清单的xmlns:机器人=htt​​p://schemas.android.com/apk/res/android
包=pt.example.project
安卓版code =1
机器人:=的versionName1.0><用途-SDK
    安卓的minSdkVersion =8
    机器人:targetSdkVersion =17/><! - 开始复印DEV Google文件 - >
<许可
    机器人:名字=pt.example.project.permission.MAPS_RECEIVE
    安卓的ProtectionLevel =签名/><使用许可权的android:NAME =pt.example.project.permission.MAPS_RECEIVE/>
<使用许可权的android:NAME =android.permission.INTERNET对/>
<使用许可权的android:NAME =android.permission.ACCESS_NETWORK_STATE/>
<使用许可权的android:NAME =android.permission.WRITE_EXTERNAL_STORAG​​E/>
<使用许可权的android:NAME =com.google.android.providers.gsf.permission.READ_GSERVICES/>
<! -
 以下两个权限不需要使用
 谷歌地图Android版API V2,但建议。 - >
<使用许可权的android:NAME =android.permission.ACCESS_COARSE_LOCATION/>
<使用许可权的android:NAME =android.permission.ACCESS_FINE_LOCATION/><用途特征
    机器人:glEsVersion =0x00020000
    机器人:要求=真/>
<! - 结束复印DEV Google文件 - ><应用
    机器人:allowBackup =真
    机器人:图标=@绘制/ ic_launcher
    机器人:标签=@字符串/ APP_NAME
    机器人:主题=@风格/ generalnotitle>
    <使用库机器人:名字=com.google.android.maps/>    <活动
        机器人:名字=pt.example.project.MainActivity
        机器人:标签=@字符串/ APP_NAME
        机器人:screenOrientation =肖像>
        &所述;意图滤光器>
            <作用机器人:名字=android.intent.action.MAIN/>            <类机器人:名字=android.intent.category.LAUNCHER/>
        &所述; /意图滤光器>
    < /活性GT;
    <活动
        机器人:名字=pt.example.project.Activity_Mapa
        机器人:标签=@字符串/ title_activity__mapa
        机器人:主题=@安卓风格/ Theme.NoTitleBar>
    < /活性GT;    &所述;元数据
        机器人:名字=com.google.android.maps.v2.API_KEY
        机器人:值=我的钥匙/>
< /用途>


解决方案

 安卓的minSdkVersion =8

您分钟SDK是8,你需要添加支持库或使分钟SDK至12

http://developer.android.com/tool​​s/extras/support- library.html

使用SupportFragment。

 的android:NAME =com.google.android.gms.maps.SupportMapFragment

从文档报价

使用MapFrament类只如果你的目标API 12以上。否则,使用SupportMapFragment。

有关详细信息,检查链接

<一个href=\"https://developers.google.com/maps/documentation/android/reference/com/google/android/gms/maps/MapFragment\" rel=\"nofollow\">https://developers.google.com/maps/documentation/android/reference/com/google/android/gms/maps/MapFragment

I know similar questions like this has been answered but I seem to have done what the tutorial suggested and reading from other posts but still I get the Inflator error. Not sure what I am doing wrong. I don't see Google-Map. Please check the code. Thanks a lot.

I generate My Key with:

keytool -list -v -keystore mystore.keystore

Activity_Map.java

package pt.example.project;

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

public class Activity_Map extends FragmentActivity {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.filexml);
    }
}

filexml.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"/>

AndroidManifest.xml

<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="pt.example.project"
android:versionCode="1"
android:versionName="1.0" >

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

<!-- START COPY DEV GOOGLE DOCS -->
<permission
    android:name="pt.example.project.permission.MAPS_RECEIVE"
    android:protectionLevel="signature" />

<uses-permission android:name="pt.example.project.permission.MAPS_RECEIVE" />
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="com.google.android.providers.gsf.permission.READ_GSERVICES" />
<!--
 The following two permissions are not required to use
 Google Maps Android API v2, but are recommended.

-->
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />

<uses-feature
    android:glEsVersion="0x00020000"
    android:required="true" />
<!-- END COPY DEV GOOGLE DOCS -->

<application
    android:allowBackup="true"
    android:icon="@drawable/ic_launcher"
    android:label="@string/app_name"
    android:theme="@style/generalnotitle" >
    <uses-library android:name="com.google.android.maps" />

    <activity
        android:name="pt.example.project.MainActivity"
        android:label="@string/app_name"
        android:screenOrientation="portrait" >
        <intent-filter>
            <action android:name="android.intent.action.MAIN" />

            <category android:name="android.intent.category.LAUNCHER" />
        </intent-filter>
    </activity>
    <activity
        android:name="pt.example.project.Activity_Mapa"
        android:label="@string/title_activity__mapa"
        android:theme="@android:style/Theme.NoTitleBar">
    </activity>

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

解决方案

    android:minSdkVersion="8"

Your min sdk is 8 you need to add support library or make your min sdk to 12

http://developer.android.com/tools/extras/support-library.html

Use SupportFragment.

 android:name="com.google.android.gms.maps.SupportMapFragment"

Quoting from the docs

Use MapFrament class only if you are targeting API 12 and above. Otherwise, use SupportMapFragment.

For more Information check the link

https://developers.google.com/maps/documentation/android/reference/com/google/android/gms/maps/MapFragment

这篇关于二进制XML文件行#2:错误充气类的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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