当前位置: 首页 > 知识库问答 >
问题:

inflating类片段时出错,原因是:Android.View.InflateException:二进制XML文件

戈宏义
2023-03-14
""apply plugin: 'com.android.application'
apply plugin: 'com.google.gms.google-services'
//apply plugin: 'com.google.gms.google-services'
android {
    compileSdkVersion 26
   //buildToolsVersion '23.0.2'

    defaultConfig {
        applicationId "sdelatorre.turisxat"
        minSdkVersion 11
        targetSdkVersion 26
        versionCode 1
        versionName "1.0"
        multiDexEnabled true
    }
    buildTypes {
        release {
            minifyEnabled true
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
        debug {
            minifyEnabled false

        }
    }
}

dependencies {
    implementation fileTree(dir: 'libs', include: ['*.jar'])
   // implementation 'com.google.firebase:firebase-messaging:17.3.4'
    testImplementation 'junit:junit:4.12'


    implementation 'com.android.support:appcompat-v7:24.1.1'
    implementation 'com.android.support:design:24.1.1'
    implementation 'org.jsoup:jsoup:1.8.1'
    implementation 'com.android.support:recyclerview-v7:23.4.0'
    implementation 'com.google.android.gms:play-services:9.2.1'
    implementation 'com.google.android.gms:play-services-gcm:8.3.0'
    implementation 'com.android.support:multidex:1.0.3'

}""
 ""<RelativeLayout
        xmlns:android="http://schemas.android.com/apk/res/android"
        xmlns:tools="http://schemas.android.com/tools"
        xmlns:app="http://schemas.android.com/apk/res-auto"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        >

        <fragment
            android:id="@+id/map"
            android:name="com.google.android.gms.maps.SupportMapFragment"
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:layout_alignParentStart="true"
            android:layout_alignParentTop="true"
            android:layout_marginStart="0dp"
            android:layout_marginTop="0dp"
            tools:context="sdelatorre.turisxat.Mapas"
            android:layout_alignParentLeft="true"
            android:layout_marginLeft="0dp" />

        <TextView
            android:id="@+id/cerca"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_alignBottom="@+id/map"
            android:layout_marginLeft="20dp"
            android:background="#ffffff"
            android:gravity="center_vertical|center_horizontal|center"
            android:textAppearance="?android:attr/textAppearanceLarge"
            android:textSize="@dimen/abc_text_size_large_material" />
    </RelativeLayout>""

I have tested the next xml and it crashes ....


    ""<?xml version="1.0" encoding="utf-8"?>
    <fragment xmlns:android="http://schemas.android.com/apk/res/android"
        xmlns:map="http://schemas.android.com/apk/res-auto"
        xmlns:tools="http://schemas.android.com/tools"
        android:id="@+id/map"
        android:name="com.google.android.gms.maps.SupportMapFragment"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        tools:context=".MapsActivity" />
    ""
""
public class Mapas extends FragmentActivity implements OnMapReadyCallback{

        private GoogleMap mMap;

        LocationManager locationManager;
        String locationProvider;
        String tipo;
        double latitude,longitude;

        @Override
        protected void onPause() {
            super.onPause();
            stopService(new Intent(this, Localizacion.class));
        }

        @Override
        protected void onResume() {
            super.onResume();
            startService(new Intent(this, Localizacion.class));
           // getActivity().startService(new Intent(getActivity(), MyService.class));
           TextView t=(TextView) findViewById(R.id.cerca);
            t.setText("GPS");
        }

        @Override
        protected void onCreate(Bundle savedInstanceState) {
            super.onCreate(savedInstanceState);
            setContentView(R.layout.activity_mapas);
            // Obtain the SupportMapFragment and get notified when the map is ready to be used.
            SupportMapFragment mapFragment = (SupportMapFragment) getSupportFragmentManager()
                    .findFragmentById(R.id.map);
            mapFragment.getMapAsync(this);
            tipo=getIntent().getExtras().getString("parametro");
            LocalBroadcastManager.getInstance(this).registerReceiver(
                    new BroadcastReceiver() {
                        @Override
                        public void onReceive(Context context, Intent intent) {
                            latitude = intent.getDoubleExtra(Localizacion.EXTRA_LATITUDE, 0);
                            longitude = intent.getDoubleExtra(Localizacion.EXTRA_LONGITUDE, 0);
                            //textView.setText("Lat: " + latitude + ", Lng: " + longitude);
                            moverCamara(latitude,longitude);

                            if (tipo.equals("UNICO")){
                    marcadoresSoloMapa();
                            }else {
                                comprueba_mas_carca(latitude, longitude);
                            }
                        }
                    }, new IntentFilter(Localizacion.ACTION_LOCATION_BROADCAST)
            );
        }""

暂时还没有答案

 类似资料: