Inflateexception

Asked

Viewed 29 times

-1

The error is as follows:

02-02 10:41:14.546 30898-30898/com.compscitutorials.basigarcia.navigationdrawervideotutorial E/AndroidRuntime: FATAL EXCEPTION: main
        Process: com.compscitutorials.basigarcia.navigationdrawervideotutorial, PID: 30898
        java.lang.RuntimeException: Unable to start activity ComponentInfo{com.compscitutorials.basigarcia.navigationdrawervideotutorial/br.com.projeto.caminhossembarreiras.MainActivity}: android.view.InflateException: Binary XML file line #6: Error inflating class fragment
            at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2412)
            at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2470)
            at android.app.ActivityThread.access$900(ActivityThread.java:174)
            at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1307)
            at android.os.Handler.dispatchMessage(Handler.java:102)
            at android.os.Looper.loop(Looper.java:146)
            at android.app.ActivityThread.main(ActivityThread.java:5593)
            at java.lang.reflect.Method.invokeNative(Native Method)
            at java.lang.reflect.Method.invoke(Method.java:515)
            at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1283)
            at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1099)
            at dalvik.system.NativeStart.main(Native Method)
        Caused by: android.view.InflateException: Binary XML file line #6: Error inflating class fragment
            at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:719)
            at android.view.LayoutInflater.rInflate(LayoutInflater.java:761)
            at android.view.LayoutInflater.inflate(LayoutInflater.java:498)
            at android.view.LayoutInflater.inflate(LayoutInflater.java:398)
            at br.com.projeto.caminhossembarreiras.MainFragment.onCreateView(MainFragment.java:25)

He points out the error in the line:

View rootView = inflater.inflate(R.layout.fragment_main, container, false);

Fragment:

<FrameLayout
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent">

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

</FrameLayout>
  • I think it might be because of the xmlns, if I’m not attracted to it I can only have one in the root element, I think if I change <fragment xmlns:android="http://schemas.android.com/apk/res/android" for <fragment will solve.

2 answers

0

The schemas shall be indicated only once and in layout outermost.

Retire xmlns:android="http://schemas.android.com/apk/res/android" of the declaration of Fragment.

<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent">

    <fragment 
        android:id="@+id/map"
        class="com.google.android.gms.maps.MapFragment"
        android:layout_width="match_parent"
        android:layout_height="match_parent">

    </fragment>
</FrameLayout>
  • I did it but the mistake I keep.

  • It’s the same mistake?

0

Or you can use the SupportMapFragment. Behold:

<FrameLayout
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent">

    <fragment
        android:id="@+id/map"
        class="com.google.android.gms.maps.SupportMapFragment"
        android:layout_width="match_parent"
        android:layout_height="match_parent" />
</FrameLayout>

See more details in the documentation.

  • This could be another problem, the current error is in line 6: <fragment xmlns:android="http://schemas.android.com/apk/res/android"

Browser other questions tagged

You are not signed in. Login or sign up in order to post.