web-dev-qa-db-ja.com

バイナリXMLファイルの行#0:クラス<unknown>の拡張エラー

クイズゲームの実行中にエラーが発生しました。このようなもの(ゲーム活動を開くとき)。アプリケーションが停止し、行#0でバイナリXMLファイルエラーが発生します。行0でこのような問題は見られなかったので、ちょっと奇妙です。だから皆さんの助けが必要です。ありがとう!

_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) 
_

MainGameActivity.Java:36は次のとおりです。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>
_

問題はどこにありますか?

7
Vhailors V

問題はライブラリ自体にあります。 attrs.xml

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

ご覧のとおり、buttonColorは色の値のみを受け入れ、[〜#〜] not [〜#〜]色参照、およびビューはxmlで渡した参照値を色に変換しようとして例外をスローするため、この属性には色のみを使用できます(like this:#000000)またはfork theプロジェクトと変更 attrs.xml このように:

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

CornerRadiusプロパティを削除してみてください。ライブラリの問題である可能性があります。

fbutton:cornerRadius="10dp"

すべてのボタンを削除し、うまく機能します

0
Munir