Android   发布时间:2022-04-28  发布网站:大佬教程  code.js-code.com
大佬教程收集整理的这篇文章主要介绍了android.view.InflateException:二进制XML文件行#2:错误膨胀类片段大佬教程大佬觉得挺不错的,现在分享给大家,也给大家做个参考。
我做的每一件事,研究每一个,但仍然没有工作.
我从这里读了很多页但没有:(

错误日志:

11-18 10:25:46.743: D/AndroidRuntime(24336): ShutTing down VM
11-18 10:25:46.743: W/dalvikvm(24336): threadid=1: thread exiTing with uncaught exception (group=0x4001d578)
11-18 10:25:46.873: E/AndroidRuntime(24336): FATAL EXCEPTION: main
11-18 10:25:46.873: E/AndroidRuntime(24336): java.lang.RuntimeException: Unable to start activity ComponenTinfo{Com.example.gmap/com.example.gmap.MainActivity}: android.view.InflateException: Binary XML file line #2: Error inflaTing class fragment
11-18 10:25:46.873: E/AndroidRuntime(24336):    at 
android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1659)
11-18 10:25:46.873: E/AndroidRuntime(24336):    at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1675)
11-18 10:25:46.873: E/AndroidRuntime(24336):    at android.app.ActivityThread.access$1500(ActivityThread.java:121)
11-18 10:25:46.873: E/AndroidRuntime(24336):    at android.app.ActivityThread$H.handlemessage(ActivityThread.java:943)
11-18 10:25:46.873: E/AndroidRuntime(24336):    at android.os.Handler.dispatchmessage(Handler.java:99)
11-18 10:25:46.873: E/AndroidRuntime(24336):    at android.os.Looper.loop(Looper.java:138)
11-18 10:25:46.873: E/AndroidRuntime(24336):    at android.app.ActivityThread.main(ActivityThread.java:3701)
11-18 10:25:46.873: E/AndroidRuntime(24336):    at java.lang.reflect.Method.invokeNative(Native Method)
11-18 10:25:46.873: E/AndroidRuntime(24336):    at java.lang.reflect.Method.invoke(Method.java:507)

主要活动:

package com.example.gmap;

import android.os.bundle;
import android.app.Activity;
import android.view.Menu;

public class MainActivity extends Activity {

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

    @Override
    public @R_450_8487@an 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;
    }

}

表现:

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://scheR_780_11845@as.android.com/apk/res/android"
    package="com.example.gmap"
    android:versionCode="1"
    android:versionName="1.0" >

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


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

    <Meta-data
    android:name="com.google.android.gms.version"
    android:value="@Integer/google_play_services_version" />

    <application
        android:allowBACkup="true"
        android:icon="@drawable/ic_launcher"
        android:label="@String/app_name"
        android:theme="@style/AppTheme" >
        <activity
            android:name="com.example.gmap.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="AIzaSyDq-Xosuk1Wzyw9WJ4bGjje6XIhD90QNuA"/>

    </application>

</manifest>

和主xml:

<?xml version="1.0" encoding="utf-8"?>
<fragment xmlns:android="http://scheR_780_11845@as.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"/>

请任何身体帮助meeee.

解决方法

改变这个

public class MainActivity extends Activity {

public class MainActivity extends FragmentActivity {

你需要以下

<Meta-data
android:name="com.google.android.gms.version"
android:value="@Integer/google_play_services_version" />

在应用程序标记它在标记之外

大佬总结

以上是大佬教程为你收集整理的android.view.InflateException:二进制XML文件行#2:错误膨胀类片段全部内容,希望文章能够帮你解决android.view.InflateException:二进制XML文件行#2:错误膨胀类片段所遇到的程序开发问题。

如果觉得大佬教程网站内容还不错,欢迎将大佬教程推荐给程序员好友。

本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。