1

我知道类似的问题已经得到解答,但我似乎已经完成了教程建议并阅读了其他帖子的内容,但我仍然收到 Inflator 错误。不知道我做错了什么。我没有看到谷歌地图。请检查代码。非常感谢。

我生成我的密钥:

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);
    }
}

文件xml.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>

4

1 回答 1

2
    android:minSdkVersion="8"

您的 min sdk 为 8,您需要添加支持库或将您的 min sdk 设置为 12

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

使用 SupportFragment。

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

从文档中引用

仅当您面向 API 12 及更高版本时才使用 MapFrament 类。否则,使用 SupportMapFragment。

有关更多信息,请查看链接

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

于 2013-05-08T10:10:40.640 回答