错误充气类片段的谷歌地图V2 [英] error inflating class fragment Google Maps v2
问题描述
我了24小时试图部署一个简单的谷歌地图V2 Android应用。我搜索了很多论坛(包括计算器)的...但我desperated。
该错误是:
android.view.InflateException:二进制XML文件行#7:错误充气类片段
这里是activity_main.xml中
<?XML版本=1.0编码=UTF-8&GT?;
<片段的xmlns:机器人=http://schemas.android.com/apk/res/android
机器人:ID =@ + ID /图的android:layout_width =match_parent
机器人:layout_height =match_parent
类=com.google.android.gms.maps.SupportMapFragment/>
MainActivity.java
包com.gotme.gotmemaps;进口android.os.Bundle;进口android.support.v4.app.FragmentActivity;
进口android.view.Menu;公共类MainActivity扩展FragmentActivity { @覆盖
保护无效的onCreate(捆绑savedInstanceState){
super.onCreate(savedInstanceState);
的setContentView(R.layout.activity_main);
} @覆盖
公共布尔onCreateOptionsMenu(菜单菜单){
//充气菜单;如果是present这增加了项目操作栏。
。getMenuInflater()膨胀(R.menu.main,菜单);
返回true;
}}
的AndroidManifest.xml
<?XML版本=1.0编码=UTF-8&GT?;
<清单的xmlns:机器人=http://schemas.android.com/apk/res/android
包=com.gotme.gotmemaps
安卓版code =1
机器人:=的versionName1.0> <用途-SDK
安卓的minSdkVersion =8
机器人:targetSdkVersion =19/><许可 机器人:名字=com.gotme.gotmemaps.permission.MAPS_RECEIVE 安卓的ProtectionLevel =签名/><使用许可权
机器人:名字=com.gotme.gotmemaps.permission.MAPS_RECEIVE/><使用许可权
机器人:名字=com.google.android.providers.gsf.permission.READ_GSERVICES/><使用许可权的android:NAME =android.permission.INTERNET对/><使用许可权的android:NAME =android.permission.WRITE_EXTERNAL_STORAGE/><使用许可权的android:NAME =android.permission.ACCESS_COARSE_LOCATION/><使用许可权的android:NAME =android.permission.ACCESS_FINE_LOCATION/><用途特征
机器人:glEsVersion =0x00020000
机器人:要求=真/> <应用
机器人:allowBackup =真
机器人:图标=@绘制/ ic_launcher
机器人:标签=@字符串/ APP_NAME
机器人:主题=@风格/ AppTheme>
<活动
机器人:名字=com.gotme.gotmemaps.MainActivity
机器人:标签=@字符串/ APP_NAME>
&所述;意图滤光器>
<作用机器人:名字=android.intent.action.MAIN/> <类机器人:名字=android.intent.category.LAUNCHER/>
&所述; /意图滤光器>
< /活性GT;
&所述;元数据
机器人:名字=com.google.android.maps.v2.API_KEY
机器人:值=AIzaSyDHfwlSoRWb6xDrpowyMWWap9Du5LQCVRM/>
< /用途>
< /清单>
我已经安装了库* google_play_services_lib *但总是得到同样的错误......
有人能帮助我吗?
非常感谢!
更新:
下面是我的logcat的:
十二月11日至19日:25:23.745:E / AndroidRuntime(7163):致命异常:主要
十二月11日至19日:25:23.745:E / AndroidRuntime(7163):了java.lang.RuntimeException:无法启动活动ComponentInfo {com.gotme.gotmemaps / com.gotme.gotmemaps.MainActivity}:android.view.InflateException:二进制XML文件行#7:错误充气类片段
十二月11日至19日:25:23.745:E / AndroidRuntime(7163):在android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2100)
十二月11日至19日:25:23.745:E / AndroidRuntime(7163):在android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2125)
十二月11日至19日:25:23.745:E / AndroidRuntime(7163):在android.app.ActivityThread.access $ 600(ActivityThread.java:140)
十二月11日至19日:25:23.745:E / AndroidRuntime(7163):在android.app.ActivityThread $ H.handleMessage(ActivityThread.java:1227)
十二月11日至19日:25:23.745:E / AndroidRuntime(7163):在android.os.Handler.dispatchMessage(Handler.java:99)
十二月11日至19日:25:23.745:E / AndroidRuntime(7163):在android.os.Looper.loop(Looper.java:137)
十二月11日至19日:25:23.745:E / AndroidRuntime(7163):在android.app.ActivityThread.main(ActivityThread.java:4898)
十二月11日至19日:25:23.745:E / AndroidRuntime(7163):在java.lang.reflect.Method.invokeNative(本机方法)
十二月11日至19日:25:23.745:E / AndroidRuntime(7163):在java.lang.reflect.Method.invoke(Method.java:511)
十二月11日至19日:25:23.745:E / AndroidRuntime(7163):在com.android.internal.os.ZygoteInit $ MethodAndArgsCaller.run(ZygoteInit.java:1006)
十二月11日至19日:25:23.745:E / AndroidRuntime(7163):在com.android.internal.os.ZygoteInit.main(ZygoteInit.java:773)
十二月11日至19日:25:23.745:E / AndroidRuntime(7163):在dalvik.system.NativeStart.main(本机方法)
十二月11日至19日:25:23.745:E / AndroidRuntime(7163):android.view.InflateException:二进制XML文件行#7:错误充气类片段产生的原因
十二月11日至19日:25:23.745:E / AndroidRuntime(7163):在android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:704)
十二月11日至19日:25:23.745:E / AndroidRuntime(7163):在android.view.LayoutInflater.rInflate(LayoutInflater.java:746)
十二月11日至19日:25:23.745:E / AndroidRuntime(7163):在android.view.LayoutInflater.inflate(LayoutInflater.java:489)
十二月11日至19日:25:23.745:E / AndroidRuntime(7163):在android.view.LayoutInflater.inflate(LayoutInflater.java:396)
十二月11日至19日:25:23.745:E / AndroidRuntime(7163):在android.view.LayoutInflater.inflate(LayoutInflater.java:352)
十二月11日至19日:25:23.745:E / AndroidRuntime(7163):在com.android.internal.policy.impl.PhoneWindow.setContentView(PhoneWindow.java:308)
十二月11日至19日:25:23.745:E / AndroidRuntime(7163):在android.app.Activity.setContentView(Activity.java:1924)
十二月11日至19日:25:23.745:E / AndroidRuntime(7163):在com.gotme.gotmemaps.MainActivity.onCreate(MainActivity.java:16)
十二月11日至19日:25:23.745:E / AndroidRuntime(7163):在android.app.Activity.performCreate(Activity.java:5206)
十二月11日至19日:25:23.745:E / AndroidRuntime(7163):在android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1083)
十二月11日至19日:25:23.745:E / AndroidRuntime(7163):在android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2064)
十二月11日至19日:25:23.745:E / AndroidRuntime(7163):11 ...更多
十二月11日至19日:25:23.745:E / AndroidRuntime(7163):java.lang.IllegalStateException:在应用的AndroidManifest.xml中的元数据标签没有正确的价值所致。预计4030500但发现0您必须在&lt中的以下声明;用途>元素:其中,元数据机器人:名字=com.google.android.gms.version机器人:值=@整数/ GOOGLE_PLAY_SERVICES_VERSION/>
十二月11日至19日:25:23.745:E / AndroidRuntime(7163):在com.google.android.gms.common.GooglePlayServicesUtil.n(来源不明)
十二月11日至19日:25:23.745:E / AndroidRuntime(7163):在com.google.android.gms.common.GooglePlayServicesUtil.isGooglePlayServicesAvailable(来源不明)
十二月11日至19日:25:23.745:E / AndroidRuntime(7163):在com.google.android.gms.maps.internal.q.v(来源不明)
十二月11日至19日:25:23.745:E / AndroidRuntime(7163):在com.google.android.gms.maps.internal.q.u(来源不明)
十二月11日至19日:25:23.745:E / AndroidRuntime(7163):在com.google.android.gms.maps.MapsInitializer.initialize(来源不明)
十二月11日至19日:25:23.745:E / AndroidRuntime(7163):在com.google.android.gms.maps.SupportMapFragment $ b.cE(来源不明)
十二月11日至19日:25:23.745:E / AndroidRuntime(7163):在com.google.android.gms.maps.SupportMapFragment $ b.a(来源不明)
十二月11日至19日:25:23.745:E / AndroidRuntime(7163):在com.google.android.gms.dynamic.a.a(来源不明)
十二月11日至19日:25:23.745:E / AndroidRuntime(7163):在com.google.android.gms.dynamic.a.onInflate(来源不明)
十二月11日至19日:25:23.745:E / AndroidRuntime(7163):在com.google.android.gms.maps.SupportMapFragment.onInflate(来源不明)
十二月11日至19日:25:23.745:E / AndroidRuntime(7163):在android.support.v4.app.FragmentActivity.onCreateView(FragmentActivity.java:290)
十二月11日至19日:25:23.745:E / AndroidRuntime(7163):在android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:676)
十二月11日至19日:25:23.745:E / AndroidRuntime(7163):21 ...更多
尝试添加<元数据机器人:名字=com.google.android.gms.version
机器人:值=@整数/ GOOGLE_PLAY_SERVICES_VERSION/>
到AndroidManifest.xml中
这对我的作品!
I've spent 24 hours trying to deploy a simple google maps v2 android apps. I've searched in a lot of forums (included stackoverflow)... but I'm desperated. The error is:
android.view.InflateException: Binary XML file line #7: Error inflating class fragment
Here is the 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" />
MainActivity.java
package com.gotme.gotmemaps;
import android.os.Bundle;
import android.support.v4.app.FragmentActivity;
import android.view.Menu;
public class MainActivity extends FragmentActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
}
@Override
public boolean onCreateOptionsMenu(Menu menu) {
// Inflate the menu; this adds items to the action bar if it is present.
getMenuInflater().inflate(R.menu.main, menu);
return true;
}
}
AndroidManifest.xml
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.gotme.gotmemaps"
android:versionCode="1"
android:versionName="1.0" >
<uses-sdk
android:minSdkVersion="8"
android:targetSdkVersion="19" />
<permission
android:name="com.gotme.gotmemaps.permission.MAPS_RECEIVE"
android:protectionLevel="signature"/>
<uses-permission
android:name="com.gotme.gotmemaps.permission.MAPS_RECEIVE"/>
<uses-permission
android:name="com.google.android.providers.gsf.permission.READ_GSERVICES"/>
<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-feature
android:glEsVersion="0x00020000"
android:required="true" />
<application
android:allowBackup="true"
android:icon="@drawable/ic_launcher"
android:label="@string/app_name"
android:theme="@style/AppTheme" >
<activity
android:name="com.gotme.gotmemaps.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="AIzaSyDHfwlSoRWb6xDrpowyMWWap9Du5LQCVRM"/>
</application>
</manifest>
I have installed the library *google_play_services_lib* but always get the same error... Could somebody help me?
Thanks a lot!
UPDATE:
Here is my logcat:
11-19 12:25:23.745: E/AndroidRuntime(7163): FATAL EXCEPTION: main
11-19 12:25:23.745: E/AndroidRuntime(7163): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.gotme.gotmemaps/com.gotme.gotmemaps.MainActivity}: android.view.InflateException: Binary XML file line #7: Error inflating class fragment
11-19 12:25:23.745: E/AndroidRuntime(7163): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2100)
11-19 12:25:23.745: E/AndroidRuntime(7163): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2125)
11-19 12:25:23.745: E/AndroidRuntime(7163): at android.app.ActivityThread.access$600(ActivityThread.java:140)
11-19 12:25:23.745: E/AndroidRuntime(7163): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1227)
11-19 12:25:23.745: E/AndroidRuntime(7163): at android.os.Handler.dispatchMessage(Handler.java:99)
11-19 12:25:23.745: E/AndroidRuntime(7163): at android.os.Looper.loop(Looper.java:137)
11-19 12:25:23.745: E/AndroidRuntime(7163): at android.app.ActivityThread.main(ActivityThread.java:4898)
11-19 12:25:23.745: E/AndroidRuntime(7163): at java.lang.reflect.Method.invokeNative(Native Method)
11-19 12:25:23.745: E/AndroidRuntime(7163): at java.lang.reflect.Method.invoke(Method.java:511)
11-19 12:25:23.745: E/AndroidRuntime(7163): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1006)
11-19 12:25:23.745: E/AndroidRuntime(7163): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:773)
11-19 12:25:23.745: E/AndroidRuntime(7163): at dalvik.system.NativeStart.main(Native Method)
11-19 12:25:23.745: E/AndroidRuntime(7163): Caused by: android.view.InflateException: Binary XML file line #7: Error inflating class fragment
11-19 12:25:23.745: E/AndroidRuntime(7163): at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:704)
11-19 12:25:23.745: E/AndroidRuntime(7163): at android.view.LayoutInflater.rInflate(LayoutInflater.java:746)
11-19 12:25:23.745: E/AndroidRuntime(7163): at android.view.LayoutInflater.inflate(LayoutInflater.java:489)
11-19 12:25:23.745: E/AndroidRuntime(7163): at android.view.LayoutInflater.inflate(LayoutInflater.java:396)
11-19 12:25:23.745: E/AndroidRuntime(7163): at android.view.LayoutInflater.inflate(LayoutInflater.java:352)
11-19 12:25:23.745: E/AndroidRuntime(7163): at com.android.internal.policy.impl.PhoneWindow.setContentView(PhoneWindow.java:308)
11-19 12:25:23.745: E/AndroidRuntime(7163): at android.app.Activity.setContentView(Activity.java:1924)
11-19 12:25:23.745: E/AndroidRuntime(7163): at com.gotme.gotmemaps.MainActivity.onCreate(MainActivity.java:16)
11-19 12:25:23.745: E/AndroidRuntime(7163): at android.app.Activity.performCreate(Activity.java:5206)
11-19 12:25:23.745: E/AndroidRuntime(7163): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1083)
11-19 12:25:23.745: E/AndroidRuntime(7163): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2064)
11-19 12:25:23.745: E/AndroidRuntime(7163): ... 11 more
11-19 12:25:23.745: E/AndroidRuntime(7163): Caused by: java.lang.IllegalStateException: The meta-data tag in your app's AndroidManifest.xml does not have the right value. Expected 4030500 but found 0. You must have the following declaration within the <application> element: <meta-data android:name="com.google.android.gms.version" android:value="@integer/google_play_services_version" />
11-19 12:25:23.745: E/AndroidRuntime(7163): at com.google.android.gms.common.GooglePlayServicesUtil.n(Unknown Source)
11-19 12:25:23.745: E/AndroidRuntime(7163): at com.google.android.gms.common.GooglePlayServicesUtil.isGooglePlayServicesAvailable(Unknown Source)
11-19 12:25:23.745: E/AndroidRuntime(7163): at com.google.android.gms.maps.internal.q.v(Unknown Source)
11-19 12:25:23.745: E/AndroidRuntime(7163): at com.google.android.gms.maps.internal.q.u(Unknown Source)
11-19 12:25:23.745: E/AndroidRuntime(7163): at com.google.android.gms.maps.MapsInitializer.initialize(Unknown Source)
11-19 12:25:23.745: E/AndroidRuntime(7163): at com.google.android.gms.maps.SupportMapFragment$b.cE(Unknown Source)
11-19 12:25:23.745: E/AndroidRuntime(7163): at com.google.android.gms.maps.SupportMapFragment$b.a(Unknown Source)
11-19 12:25:23.745: E/AndroidRuntime(7163): at com.google.android.gms.dynamic.a.a(Unknown Source)
11-19 12:25:23.745: E/AndroidRuntime(7163): at com.google.android.gms.dynamic.a.onInflate(Unknown Source)
11-19 12:25:23.745: E/AndroidRuntime(7163): at com.google.android.gms.maps.SupportMapFragment.onInflate(Unknown Source)
11-19 12:25:23.745: E/AndroidRuntime(7163): at android.support.v4.app.FragmentActivity.onCreateView(FragmentActivity.java:290)
11-19 12:25:23.745: E/AndroidRuntime(7163): at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:676)
11-19 12:25:23.745: E/AndroidRuntime(7163): ... 21 more
try to add
<meta-data android:name="com.google.android.gms.version"
android:value="@integer/google_play_services_version" />
into AndroidManifest.xml
It works for me!
这篇关于错误充气类片段的谷歌地图V2的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!