webentwicklung-frage-antwort-db.com.de

Binäre XML-Dateizeile # 0: Fehler beim Aufblasen der Klasse <unbekannt>

Ich habe einen Fehler beim Ausführen eines Quizspiels. So etwas (bei offener Gameaktivität). Meine Anwendung wird gestoppt und ich habe einen binären XML-Dateifehler in Zeile 0. Es ist irgendwie komisch, weil ich mit Zeile 0 kein Problem wie dieses gesehen habe, also brauche ich deine Hilfe, alle. Vielen Dank!

E/AndroidRuntime: FATAL EXCEPTION: main
   Process: sarveshchavan777.triviaquiz, PID: 2901
   Java.lang.RuntimeException: Unable to start activity ComponentInfo{sarveshchavan777.triviaquiz/sarveshchavan777.triviaquiz.MainGameActivity}: Android.view.InflateException: Binary XML file line #0: Binary XML file line #0: Error inflating class <unknown>
       at Android.app.ActivityThread.performLaunchActivity(ActivityThread.Java:2817)
       at Android.app.ActivityThread.handleLaunchActivity(ActivityThread.Java:2892)
       at Android.app.ActivityThread.-wrap11(Unknown Source:0)
       at Android.app.ActivityThread$H.handleMessage(ActivityThread.Java:1593)
       at Android.os.Handler.dispatchMessage(Handler.Java:105)
       at Android.os.Looper.loop(Looper.Java:164)
       at Android.app.ActivityThread.main(ActivityThread.Java:6540)
       at Java.lang.reflect.Method.invoke(Native Method)
       at com.Android.internal.os.Zygote$MethodAndArgsCaller.run(Zygote.Java:240)
       at com.Android.internal.os.ZygoteInit.main(ZygoteInit.Java:767)
    Caused by: Android.view.InflateException: Binary XML file line #0: Binary XML file line #0: Error inflating class <unknown>
    Caused by: Android.view.InflateException: Binary XML file line #0: Error inflating class <unknown>
    Caused by: Java.lang.reflect.InvocationTargetException
       at Java.lang.reflect.Constructor.newInstance0(Native Method)
       at Java.lang.reflect.Constructor.newInstance(Constructor.Java:334)
       at Android.view.LayoutInflater.createView(LayoutInflater.Java:650)
       at Android.view.LayoutInflater.createViewFromTag(LayoutInflater.Java:793)
       at Android.view.LayoutInflater.createViewFromTag(LayoutInflater.Java:733)
       at Android.view.LayoutInflater.rInflate(LayoutInflater.Java:866)
       at Android.view.LayoutInflater.rInflateChildren(LayoutInflater.Java:827)
       at Android.view.LayoutInflater.rInflate(LayoutInflater.Java:869)
       at Android.view.LayoutInflater.rInflateChildren(LayoutInflater.Java:827)
       at Android.view.LayoutInflater.inflate(LayoutInflater.Java:518)
       at Android.view.LayoutInflater.inflate(LayoutInflater.Java:426)
       at Android.view.LayoutInflater.inflate(LayoutInflater.Java:377)
       at Android.support.v7.app.AppCompatDelegateImplV9.setContentView(AppCompatDelegateImplV9.Java:288)
       at Android.support.v7.app.AppCompatActivity.setContentView(AppCompatActivity.Java:143)
       at sarveshchavan777.triviaquiz.MainGameActivity.onCreate(MainGameActivity.Java:36)
       at Android.app.Activity.performCreate(Activity.Java:6980)
       at Android.app.Instrumentation.callActivityOnCreate(Instrumentation.Java:1213)
       at Android.app.ActivityThread.performLaunchActivity(ActivityThread.Java:2770)
       at Android.app.ActivityThread.handleLaunchActivity(ActivityThread.Java:2892)
       at Android.app.ActivityThread.-wrap11(Unknown Source:0)
       at Android.app.ActivityThread$H.handleMessage(ActivityThread.Java:1593)
       at Android.os.Handler.dispatchMessage(Handler.Java:105)
       at Android.os.Looper.loop(Looper.Java:164)
       at Android.app.ActivityThread.main(ActivityThread.Java:6540)
       at Java.lang.reflect.Method.invoke(Native Method)
       at com.Android.internal.os.Zygote$MethodAndArgsCaller.run(Zygote.Java:240)
       at com.Android.internal.os.ZygoteInit.main(ZygoteInit.Java:767)
    Caused by: Java.lang.UnsupportedOperationException: Can't convert value at index 1 to color: type=0x5
       at Android.content.res.TypedArray.getColor(TypedArray.Java:473)
       at info.hoang8f.widget.FButton.parseAttrs(FButton.Java:116)
       at info.hoang8f.widget.FButton.<init>(FButton.Java:52)
       at Java.lang.reflect.Constructor.newInstance0(Native Method) 
       at Java.lang.reflect.Constructor.newInstance(Constructor.Java:334) 
       at Android.view.LayoutInflater.createView(LayoutInflater.Java:650) 
       at Android.view.LayoutInflater.createViewFromTag(LayoutInflater.Java:793) 
       at Android.view.LayoutInflater.createViewFromTag(LayoutInflater.Java:733) 
       at Android.view.LayoutInflater.rInflate(LayoutInflater.Java:866) 
       at Android.view.LayoutInflater.rInflateChildren(LayoutInflater.Java:827) 
       at Android.view.LayoutInflater.rInflate(LayoutInflater.Java:869) 
       at Android.view.LayoutInflater.rInflateChildren(LayoutInflater.Java:827) 
       at Android.view.LayoutInflater.inflate(LayoutInflater.Java:518) 
       at Android.view.LayoutInflater.inflate(LayoutInflater.Java:426) 
       at Android.view.LayoutInflater.inflate(LayoutInflater.Java:377) 
       at Android.support.v7.app.AppCompatDelegateImplV9.setContentView(AppCompatDelegateImplV9.Java:288) 
       at Android.support.v7.app.AppCompatActivity.setContentView(AppCompatActivity.Java:143) 
       at sarveshchavan777.triviaquiz.MainGameActivity.onCreate(MainGameActivity.Java:36) 
       at Android.app.Activity.performCreate(Activity.Java:6980) 
       at Android.app.Instrumentation.callActivityOnCreate(Instrumentation.Java:1213) 
       at Android.app.ActivityThread.performLaunchActivity(ActivityThread.Java:2770) 
       at Android.app.ActivityThread.handleLaunchActivity(ActivityThread.Java:2892) 
       at Android.app.ActivityThread.-wrap11(Unknown Source:0) 
       at Android.app.ActivityThread$H.handleMessage(ActivityThread.Java:1593) 
       at Android.os.Handler.dispatchMessage(Handler.Java:105) 
       at Android.os.Looper.loop(Looper.Java:164) 
       at Android.app.ActivityThread.main(ActivityThread.Java:6540) 
       at Java.lang.reflect.Method.invoke(Native Method) 
       at com.Android.internal.os.Zygote$MethodAndArgsCaller.run(Zygote.Java:240) 
       at com.Android.internal.os.ZygoteInit.main(ZygoteInit.Java:767) 

Wo MainGameActivity.Java:36 ist: setContentView(R.layout.activity_game_main);

Activity_game_main.xml:

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:Android="http://schemas.Android.com/apk/res/Android"
    xmlns:fbutton="http://schemas.Android.com/apk/res-auto"
    xmlns:tools="http://schemas.Android.com/tools"
    Android:id="@+id/activity_main"
    Android:layout_width="match_parent"
    Android:layout_height="match_parent"
    Android:background="@color/backgroundColor"
    Android:orientation="vertical"
    tools:context="sarveshchavan777.triviaquiz.MainGameActivity">

    <Android.support.v7.widget.Toolbar
        Android:id="@+id/toolbar"
        Android:layout_width="match_parent"
        Android:layout_height="50dp"
        Android:background="@color/lightGreen"
        Android:minHeight="?actionBarSize">

        <RelativeLayout
            Android:layout_width="match_parent"
            Android:layout_height="wrap_content"
            Android:padding="0dp">



            <TextView
                Android:id="@+id/triviaQuizText"
                Android:layout_width="match_parent"
                Android:layout_height="match_parent"
                Android:gravity="center"
                Android:text="@string/app_name"
                Android:textColor="@color/white"
                Android:textSize="25sp"
                Android:layout_toLeftOf="@+id/timeText"
                Android:layout_toRightOf="@+id/coinText" />

            <TextView
                Android:id="@+id/timeText"
                Android:layout_width="wrap_content"
                Android:layout_height="match_parent"
                Android:layout_alignParentEnd="true"
                Android:layout_alignParentRight="true"
                Android:paddingLeft="10dp"
                Android:gravity="center"
                Android:paddingRight="10dp"
                Android:text="@string/time"
                Android:textSize="20sp" />

        </RelativeLayout>
    </Android.support.v7.widget.Toolbar>

    <View
        Android:layout_width="match_parent"
        Android:layout_height="10dp"></View>

    <LinearLayout
        Android:layout_width="match_parent"
        Android:layout_height="0dp"
        Android:layout_weight=".5"
        Android:background="@color/white"
        Android:orientation="vertical">

        <TextView
            Android:id="@+id/triviaQuestion"
            Android:layout_width="match_parent"
            Android:layout_height="wrap_content"
            Android:layout_margin="20dp"
            Android:gravity="center"
            Android:text="@string/question"
            Android:textColor="@color/grey"
            Android:textSize="18sp" />

        <TextView
            Android:id="@+id/resultText"
            Android:layout_width="match_parent"
            Android:layout_height="wrap_content"
            Android:gravity="center"
            Android:text=""
            Android:textColor="@color/green"
            Android:textSize="30sp" />
    </LinearLayout>


    <LinearLayout
        Android:layout_width="match_parent"
        Android:layout_height="0dp"
        Android:layout_weight="1"
        Android:gravity="center"
        Android:orientation="vertical">

        <info.hoang8f.widget.FButton
            Android:id="@+id/buttonA"
            Android:layout_width="match_parent"
            Android:layout_height="wrap_content"
            Android:layout_margin="10dp"
            Android:onClick="buttonA"
            Android:text=""
            Android:textColor="@color/grey"
            fbutton:buttonColor="@color/white"
            fbutton:cornerRadius="10dp"
            fbutton:shadowColor="@color/grey" />

        <info.hoang8f.widget.FButton
            Android:id="@+id/buttonB"
            Android:layout_width="match_parent"
            Android:layout_height="wrap_content"
            Android:layout_margin="10dp"
            Android:onClick="buttonB"
            Android:text=""
            Android:textColor="@color/grey"
            fbutton:buttonColor="@color/white"
            fbutton:cornerRadius="10dp"
            fbutton:shadowColor="@color/grey" />


        <info.hoang8f.widget.FButton
            Android:id="@+id/buttonC"
            Android:layout_width="match_parent"
            Android:layout_height="wrap_content"
            Android:layout_margin="10dp"
            Android:onClick="buttonC"
            Android:text=""
            Android:textColor="@color/grey"
            fbutton:buttonColor="@color/white"
            fbutton:cornerRadius="10dp"
            fbutton:shadowColor="@color/grey" />

        <info.hoang8f.widget.FButton
            Android:id="@+id/buttonD"
            Android:layout_width="match_parent"
            Android:layout_height="wrap_content"
            Android:layout_margin="10dp"
            Android:onClick="buttonD"
            Android:text=""
            Android:textColor="@color/grey"
            fbutton:buttonColor="@color/white"
            fbutton:cornerRadius="10dp"
            fbutton:shadowColor="@color/grey" />

    </LinearLayout>


</LinearLayout>

Wo ist das Problem?

7
Vhailors V

Das Problem tritt bei der Bibliothek selbst auf. Wenn Sie attrs.xml überprüfen:

<attr name="buttonColor" format="color" />

Wie Sie sehen, akzeptiert die Variable buttonColor nur den Farbwert NICHT, und die Ansicht versucht, den in xml übergebenen Referenzwert in eine Farbe umzuwandeln, und es wird eine Ausnahme ausgelöst. Sie können also nur Farbe verwenden Attribut (wie folgt: # 000000) Oder das Projekt verzweigen und attrs.xml wie folgt ändern:

<attr name="buttonColor" format="color|reference" />
8

Versuchen Sie, die cornerRadius -Eigenschaft zu entfernen, da dies zu Bibliotheksproblemen führt

fbutton:cornerRadius="10dp"

Entfernen Sie alle Knöpfe und es funktioniert gut

0
Munir