1

我知道类似这样的问题已经得到解答,但我似乎已经完成了本教程的建议,并从其他帖子中阅读,但仍然收到了Inflator错误。不知道我做错了什么。我没有看到Google-Map。请检查代码。非常感谢。二进制XML文件行#2:错误膨胀类

我产生我与重点:

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

在什么地方发生错误? “b_mapa.xml”是什么样的? – TomTasche 2013-05-08 10:04:41

+0

不,错误是“致命异常:主要”和“java.lang.RuntimeException:无法启动活动ComponentInfo {pt.example.project/pt.example.project.Activity_Mapa}:android.view.InflateException:二进制XML文件行#2:错误膨胀类片段“ 。 而b_mapa.xml是filexml.xml对不起 – nss 2013-05-08 10:40:09

回答

2
android:minSdkVersion="8" 

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

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

使用SupportFragment 8。

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

从文档

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

欲了解更多信息检查链接

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

+0

谢谢,但错误继续: 二进制XML文件行#2:错误膨胀类 。 我认为问题出在Activity和Fragment之间,但是我不知道 – nss 2013-05-08 10:31:54

+0

非常感谢你@Raghunandan,没想到这对我来说是这样,但即使我使用的是不支持的库。再次感谢Ash。 – Ash 2013-05-23 19:19:20

+0

@Ash很高兴帮助你 – Raghunandan 2013-05-23 19:20:13

相关问题