web-dev-qa-db-fra.com

android.view.InflateException: ligne de fichier XML binaire n ° 6: erreur lors de l'inflagration du fragment de classe

Cette erreur se produit au démarrage de l'application

Je reçois beaucoup d'erreurs de genre affichées dans le sujet. Ces erreurs semblent être occasionnelles et je ne peux pas les reproduire. De la pile, je peux apprendre qu'une telle erreur peut se produire pour mes différentes ressources de présentation. La ligne de XML varie également.

Quelqu'un peut-il expliquer pourquoi cette erreur se produit? Et ce que je peux faire pour résoudre ce problème?

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)

Cette erreur se produit lorsque l'application démarre, j'ai besoin d'aide s'il vous plaît

Voici un résultat de XML, cependant une telle erreur se produit dans d’autres fichiers XML

<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>
8
Carrobe90
<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>

est dans l'élément de AndroidManifest.xml

11
mrkaktooz

utilisation

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

au lieu de

import Android.app.Fragment;
YourActivity extends Activity 

et s'il vous plaît ajouter la clé API dans votre fichier manifeste

8
Ketan Ahir

vous devez ajouter cette balise dans votre fichier AndroidManifest:

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

Votre logcat indique que vous n'avez pas ajouté de API KEY dans votre fichier AndroidManifest.

Veuillez ajouter la clé API dans votre fichier manifeste comme ci-dessous:

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

Si vous essayez d'afficher la carte dans Fragment, vous devez écrire le nom de la classe comme suit:

   <?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"/>
0
GrIsHu