Home » Android » java – android.view.InflateException: Binary XML file line #6: Error inflating class fragemnt

java – android.view.InflateException: Binary XML file line #6: Error inflating class fragemnt

Posted by: admin June 15, 2020 Leave a comment

Questions:

This error occurs when the application starts

I am receiving many errors of kind displayed in the subj. These errors seems to be occasional and I cannot reproduce them. From stack I can learn that such error may occurs for my different layout resources. The line of XML is also varying.

Can anybody explain why this error occurs? And what I can do to fix this problem?

09-06 00:15:33.254: E/AndroidRuntime(7812): FATAL EXCEPTION: main
09-06 00:15:33.254: E/AndroidRuntime(7812): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.touchboarder.example.videostream/com.touchboarder.example.videostream.Activity_Mapa}: android.view.InflateException: Binary XML file line #6: Error inflating class fragment
09-06 00:15:33.254: E/AndroidRuntime(7812):     at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2100)
09-06 00:15:33.254: E/AndroidRuntime(7812):     at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2125)
09-06 00:15:33.254: E/AndroidRuntime(7812):     at android.app.ActivityThread.access$600(ActivityThread.java:140)
09-06 00:15:33.254: E/AndroidRuntime(7812):     at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1227)
09-06 00:15:33.254: E/AndroidRuntime(7812):     at android.os.Handler.dispatchMessage(Handler.java:99)
09-06 00:15:33.254: E/AndroidRuntime(7812):     at android.os.Looper.loop(Looper.java:137)
09-06 00:15:33.254: E/AndroidRuntime(7812):     at android.app.ActivityThread.main(ActivityThread.java:4898)
09-06 00:15:33.254: E/AndroidRuntime(7812):     at java.lang.reflect.Method.invokeNative(Native Method)
09-06 00:15:33.254: E/AndroidRuntime(7812):     at java.lang.reflect.Method.invoke(Method.java:511)
09-06 00:15:33.254: E/AndroidRuntime(7812):     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1006)
09-06 00:15:33.254: E/AndroidRuntime(7812):     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:773)
09-06 00:15:33.254: E/AndroidRuntime(7812):     at dalvik.system.NativeStart.main(Native Method)
09-06 00:15:33.254: E/AndroidRuntime(7812): Caused by: android.view.InflateException: Binary XML file line #6: Error inflating class fragment
09-06 00:15:33.254: E/AndroidRuntime(7812):     at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:704)
09-06 00:15:33.254: E/AndroidRuntime(7812):     at android.view.LayoutInflater.rInflate(LayoutInflater.java:746)
09-06 00:15:33.254: E/AndroidRuntime(7812):     at android.view.LayoutInflater.inflate(LayoutInflater.java:489)
09-06 00:15:33.254: E/AndroidRuntime(7812):     at android.view.LayoutInflater.inflate(LayoutInflater.java:396)
09-06 00:15:33.254: E/AndroidRuntime(7812):     at android.view.LayoutInflater.inflate(LayoutInflater.java:352)
09-06 00:15:33.254: E/AndroidRuntime(7812):     at com.android.internal.policy.impl.PhoneWindow.setContentView(PhoneWindow.java:308)
09-06 00:15:33.254: E/AndroidRuntime(7812):     at android.app.Activity.setContentView(Activity.java:1924)
09-06 00:15:33.254: E/AndroidRuntime(7812):     at com.touchboarder.example.videostream.Activity_Mapa.onCreate(Activity_Mapa.java:59)
09-06 00:15:33.254: E/AndroidRuntime(7812):     at android.app.Activity.performCreate(Activity.java:5206)
09-06 00:15:33.254: E/AndroidRuntime(7812):     at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1083)
09-06 00:15:33.254: E/AndroidRuntime(7812):     at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2064)
09-06 00:15:33.254: E/AndroidRuntime(7812):     ... 11 more
09-06 00:15:33.254: E/AndroidRuntime(7812): Caused by: java.lang.RuntimeException: API key not found.  Check that <meta-data android:name="com.google.android.maps.v2.API_KEY" android:value="your API key"/> is in the <application> element of AndroidManifest.xml
09-06 00:15:33.254: E/AndroidRuntime(7812):     at maps.ag.bb.a(Unknown Source)
09-06 00:15:33.254: E/AndroidRuntime(7812):     at maps.ag.bb.a(Unknown Source)
09-06 00:15:33.254: E/AndroidRuntime(7812):     at maps.ag.an.a(Unknown Source)
09-06 00:15:33.254: E/AndroidRuntime(7812):     at maps.ag.bi.a(Unknown Source)
09-06 00:15:33.254: E/AndroidRuntime(7812):     at maps.ag.bh.a(Unknown Source)
09-06 00:15:33.254: E/AndroidRuntime(7812):     at blf.onTransact(SourceFile:107)
09-06 00:15:33.254: E/AndroidRuntime(7812):     at android.os.Binder.transact(Binder.java:326)
09-06 00:15:33.254: E/AndroidRuntime(7812):     at com.google.android.gms.maps.internal.IMapFragmentDelegate$a$a.onCreateView(Unknown Source)
09-06 00:15:33.254: E/AndroidRuntime(7812):     at com.google.android.gms.maps.SupportMapFragment$a.onCreateView(Unknown Source)
09-06 00:15:33.254: E/AndroidRuntime(7812):     at com.google.android.gms.internal.bh$4.b(Unknown Source)
09-06 00:15:33.254: E/AndroidRuntime(7812):     at com.google.android.gms.internal.bh.a(Unknown Source)
09-06 00:15:33.254: E/AndroidRuntime(7812):     at com.google.android.gms.internal.bh.onCreateView(Unknown Source)
09-06 00:15:33.254: E/AndroidRuntime(7812):     at com.google.android.gms.maps.SupportMapFragment.onCreateView(Unknown Source)
09-06 00:15:33.254: E/AndroidRuntime(7812):     at android.support.v4.app.Fragment.performCreateView(Fragment.java:1478)
09-06 00:15:33.254: E/AndroidRuntime(7812):     at android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:900)
09-06 00:15:33.254: E/AndroidRuntime(7812):     at android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:1082)
09-06 00:15:33.254: E/AndroidRuntime(7812):     at android.support.v4.app.FragmentManagerImpl.addFragment(FragmentManager.java:1184)
09-06 00:15:33.254: E/AndroidRuntime(7812):     at android.support.v4.app.FragmentActivity.onCreateView(FragmentActivity.java:285)
09-06 00:15:33.254: E/AndroidRuntime(7812):     at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:676)

This error occurs when the application starts
i need help please

Here is a result of XML, however such error occurs in other xmls

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

    </LinearLayout>

mi manifestbut i don't found the mistake

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

        <meta-data
                android:name="com.google.android.maps.v2.API_KEY"
                android:value="AIzaSyCZG-M6IwXlt46Y37Ip9bp0WdV-shyC39w"/>

        <uses-sdk android:minSdkVersion="7" />

        <uses-permission
        android:name="com.touchboarder.example.videostream.permission.MAPS_RECEIVE"
        android:protectionLevel="signature"/>

        <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-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>
        <uses-permission android:name="android.permission.ACCESS_MOCK_LOCATION"/>
        <uses-permission android:name="android.permission.ACCESS_WIFI_STATE"/>
        <uses-permission android:name="android.permission.INTERNET"/>
        <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>

         <uses-feature
            android:glEsVersion="0x00020000"
            android:required="true" />  

        <application
            android:icon="@drawable/ic_launcher"
            android:label="@string/app_name"        
            android:theme="@android:style/Theme.Holo.Light.NoActionBar.Fullscreen">
            <activity
                android:name=".Activity_Home"
                android:label="@string/app_name"
                android:configChanges="orientation|keyboardHidden"
                >
                <intent-filter>
                    <action android:name="android.intent.action.MAIN" />
                    <category android:name="android.intent.category.LAUNCHER" />
                </intent-filter>
            </activity>
            <activity android:name=".Activity_Reserva" android:label="@string/app_name" android:screenOrientation="portrait"
              android:configChanges="orientation|keyboardHidden|screenSize">          
          </activity>          
            <activity android:name=".Activity_Registro" android:screenOrientation="portrait">           
            </activity> 

             <activity android:name=".Activity_Mapa" >           
            </activity>     



</application>

    </manifest>
How to&Answers:
<application>
        <meta-data
            android:name="com.google.android.maps.v2.API_KEY"
            android:value="youApiKey" 

        />
    <meta-data 
            android:name="com.google.android.gms.version"
            android:value="@integer/google_play_services_version" 
        />
</application>

is in the element of AndroidManifest.xml

Answer:

use

import android.support.v4.app.Fragment;
YourActivity extends FragmentActivity 

instead of

import android.app.Fragment;
YourActivity extends Activity 

and Please add the API KEY in your manifest file

Answer:

you should add this tag in your AndroidManifest file:

<meta-data
        android:name="com.google.android.maps.v2.API_KEY"
        android:value="your APi key here" />

Answer:

Your logcat shows that you have not added a API KEY in your AndroidManifest file.

Please add the API KEY in your manifest file as below:

<meta-data
        android:name="com.google.android.maps.v2.API_KEY"
        android:value="your APi key here" />

If you are trying to show map in Fragment then in your layout file you have to write class name as below:

   <?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"
      android:name="com.google.android.gms.maps.SupportMapFragment"/>