gpt4 book ai didi

安卓.view.InflateException : Binary XML file line #1: error inflating class fragment/from an emulator

转载 作者:行者123 更新时间:2023-11-30 03:13:22 25 4
gpt4 key购买 nike

我正在尝试制作一个简单的 map 并在模拟器中对其进行调试。我想知道我的错误在哪里,我该如何纠正。

这是:Logcat:

12-12 15:32:28.310: D/dalvikvm(879): Not late-enabling CheckJNI (already on)
12-12 15:32:30.070: D/AndroidRuntime(879): Shutting down VM
12-12 15:32:30.070: W/dalvikvm(879): threadid=1: thread exiting with uncaught exception (group=0xb3abdb90)
12-12 15:32:30.150: E/AndroidRuntime(879): FATAL EXCEPTION: main
12-12 15:32:30.150: E/AndroidRuntime(879): Process: com.exemple.mysecondapp, PID: 879
12-12 15:32:30.150: E/AndroidRuntime(879): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.exemple.mysecondapp/com.exemple.mysecondapp.MainActivity}: android.view.InflateException: Binary XML file line #1: Error inflating class fragment
12-12 15:32:30.150: E/AndroidRuntime(879): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2176)
12-12 15:32:30.150: E/AndroidRuntime(879): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2226)
12-12 15:32:30.150: E/AndroidRuntime(879): at android.app.ActivityThread.access$700(ActivityThread.java:135)
12-12 15:32:30.150: E/AndroidRuntime(879): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1397)
12-12 15:32:30.150: E/AndroidRuntime(879): at android.os.Handler.dispatchMessage(Handler.java:102)
12-12 15:32:30.150: E/AndroidRuntime(879): at android.os.Looper.loop(Looper.java:137)
12-12 15:32:30.150: E/AndroidRuntime(879): at android.app.ActivityThread.main(ActivityThread.java:4998)
12-12 15:32:30.150: E/AndroidRuntime(879): at java.lang.reflect.Method.invokeNative(Native Method)
12-12 15:32:30.150: E/AndroidRuntime(879): at java.lang.reflect.Method.invoke(Method.java:515)
12-12 15:32:30.150: E/AndroidRuntime(879): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:777)
12-12 15:32:30.150: E/AndroidRuntime(879): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:593)
12-12 15:32:30.150: E/AndroidRuntime(879): at dalvik.system.NativeStart.main(Native Method)
12-12 15:32:30.150: E/AndroidRuntime(879): Caused by: android.view.InflateException: Binary XML file line #1: Error inflating class fragment
12-12 15:32:30.150: E/AndroidRuntime(879): at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:713)
12-12 15:32:30.150: E/AndroidRuntime(879): at android.view.LayoutInflater.inflate(LayoutInflater.java:469)
12-12 15:32:30.150: E/AndroidRuntime(879): at android.view.LayoutInflater.inflate(LayoutInflater.java:397)
12-12 15:32:30.150: E/AndroidRuntime(879): at android.view.LayoutInflater.inflate(LayoutInflater.java:353)
12-12 15:32:30.150: E/AndroidRuntime(879): at com.android.internal.policy.impl.PhoneWindow.setContentView(PhoneWindow.java:290)
12-12 15:32:30.150: E/AndroidRuntime(879): at android.app.Activity.setContentView(Activity.java:1928)
12-12 15:32:30.150: E/AndroidRuntime(879): at com.exemple.mysecondapp.MainActivity.onCreate(MainActivity.java:21)
12-12 15:32:30.150: E/AndroidRuntime(879): at android.app.Activity.performCreate(Activity.java:5243)
12-12 15:32:30.150: E/AndroidRuntime(879): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1087)
12-12 15:32:30.150: E/AndroidRuntime(879): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2140)
12-12 15:32:30.150: E/AndroidRuntime(879): ... 11 more
12-12 15:32:30.150: E/AndroidRuntime(879): 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" />
12-12 15:32:30.150: E/AndroidRuntime(879): at com.google.android.gms.common.GooglePlayServicesUtil.n(Unknown Source)
12-12 15:32:30.150: E/AndroidRuntime(879): at com.google.android.gms.common.GooglePlayServicesUtil.isGooglePlayServicesAvailable(Unknown Source)
12-12 15:32:30.150: E/AndroidRuntime(879): at com.google.android.gms.maps.internal.q.v(Unknown Source)
12-12 15:32:30.150: E/AndroidRuntime(879): at com.google.android.gms.maps.internal.q.u(Unknown Source)
12-12 15:32:30.150: E/AndroidRuntime(879): at com.google.android.gms.maps.MapsInitializer.initialize(Unknown Source)
12-12 15:32:30.150: E/AndroidRuntime(879): at com.google.android.gms.maps.SupportMapFragment$b.cE(Unknown Source)
12-12 15:32:30.150: E/AndroidRuntime(879): at com.google.android.gms.maps.SupportMapFragment$b.a(Unknown Source)
12-12 15:32:30.150: E/AndroidRuntime(879): at com.google.android.gms.dynamic.a.a(Unknown Source)
12-12 15:32:30.150: E/AndroidRuntime(879): at com.google.android.gms.dynamic.a.onInflate(Unknown Source)
12-12 15:32:30.150: E/AndroidRuntime(879): at com.google.android.gms.maps.SupportMapFragment.onInflate(Unknown Source)
12-12 15:32:30.150: E/AndroidRuntime(879): at android.support.v4.app.FragmentActivity.onCreateView(FragmentActivity.java:290)
12-12 15:32:30.150: E/AndroidRuntime(879): at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:685)
12-12 15:32:30.150: E/AndroidRuntime(879): ... 20 more
12-12 15:34:25.171: I/Process(879): Sending signal. PID: 879 SIG: 9

主类:

package com.exemple.mysecondapp;

import com.google.android.gms.common.ConnectionResult;
import com.google.android.gms.common.GooglePlayServicesUtil;
import com.google.android.gms.maps.GoogleMap;
import com.google.android.gms.maps.SupportMapFragment;

import android.app.Dialog;
import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentActivity;


public class MainActivity extends FragmentActivity {
private GoogleMap gm;

@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);

setContentView(R.layout.activity_main);

int status = GooglePlayServicesUtil.isGooglePlayServicesAvailable(getBaseContext());

if (status == ConnectionResult.SUCCESS) {
SupportMapFragment supportMapFragment = (SupportMapFragment) getSupportFragmentManager().findFragmentById(R.id.map);
}
else {
int requestCode = 10;
Dialog dialog = GooglePlayServicesUtil.getErrorDialog(status, this, requestCode);
dialog.show();
}
}

}

activity_main.xml:

<fragment xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/map"
android:name="com.google.android.gms.maps.SupportMapFragment"
android:layout_width="match_parent"
android:layout_height="match_parent"
class="com.google.android.gms.maps.SupportMapFragment"/>

应用 list :

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.exemple.mysecondapp"
android:versionCode="1"
android:versionName="1.0" >

<uses-sdk
android:minSdkVersion="12"
android:targetSdkVersion="19" />

<application
android:allowBackup="true"
android:icon="@drawable/ic_launcher"
android:label="@string/app_name"
android:theme="@style/AppTheme" >
<activity
android:name="com.exemple.mysecondapp.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>
<uses-library android:required="true" android:name="com.google.android.maps" />


<meta-data
android:name="com.google.android.maps.v2.API_KEY"
android:value="AN API KEY"/>
</application>
<meta-data
android:name="com.google.android.gms.version"
android:value="@integer/google_play_services_version" />


<permission
android:name="com.exemple.mysecondapp.permission.MAPS_RECEIVE"
android:protectionLevel="signature"/>
<uses-permission android:name="com.exemple.mysecondapp.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"/>
<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"/>

我为此花费了很多时间,但迄今为止还没有有效的答案。感谢回答此问题的任何人。

最佳答案

The meta-data tag in your app's AndroidManifest.xml does not have the right value.  Expected 4030500 but found 0.

您应该在模拟器中安装 google play 服务(基于 Android 4.2.2 或更高版本)

http://developer.android.com/google/play-services/setup.html

关于安卓.view.InflateException : Binary XML file line #1: error inflating class fragment/from an emulator,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20554087/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com