Binary XML file line #2: Error inflating class

对着背影说爱祢 提交于 2019-12-11 06:49:53

问题


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>


回答1:


    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



来源:https://stackoverflow.com/questions/16437798/binary-xml-file-line-2-error-inflating-class

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!