无法启动活动ComponentInfo?android.view.InflateException:二进制XML文件行#8:错误导致类<unknown>

时间:2017-12-07 05:37:19

标签: android xml android-8.0-oreo

我正在尝试在Android应用中创建一个页面。除了拥有Android 8.0的手机外,它在所有手机中都运行良好。这是XML文件代码

        <?xml version="1.0" encoding="utf-8"?>
        <LinearLayout 
        xmlns:android="http://schemas.android.com/apk/res/android"
        android:orientation="vertical" android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:background="@drawable/bg3_logo"
        >

        <TextView
                android:id="@+id/text1d"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"       

                android:layout_marginTop="14dp"
                android:enabled="true"
                android:maxLength="50"
                android:text="Welcome Customer xxxxxx"
                android:textSize="12sp"
                android:textStyle="bold" />

            <TextView
                android:id="@+id/text2d"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"


                android:enabled="true"
                android:maxLength="50"
                android:text="" />

                 <LinearLayout
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:orientation="horizontal" >

                    <TextView
                           android:id="@+id/textView"
                           android:layout_width="wrap_content"
                           android:layout_height="wrap_content"
                           android:layout_alignParentLeft="true"
                           android:layout_alignTop="@+id/imageButton1"
                           android:gravity="center"
                           android:singleLine="false"
                           android:text=""
                           android:textSize="12dp" />

                    <TextView
                            android:id="@+id/text3"
                            android:layout_width="wrap_content"
                            android:layout_height="wrap_content"

                            android:layout_below="@+id/text2"
                            android:enabled="true"
                            android:maxLength="50"
                            android:text=""
                            android:textSize="12dp"
                             />
                </LinearLayout>

               <LinearLayout
                   android:layout_width="wrap_content"
                   android:layout_height="wrap_content"
                   android:orientation="horizontal" >

                   <ImageButton
                       android:id="@+id/imageButton12"
                       android:layout_width="15dp"
                       android:layout_height="15dp"

                       android:layout_below="@+id/textView3"
                       android:layout_marginRight="14dp"
                       android:background="@drawable/rotate6"
                       android:contentDescription="From Date" />

             </LinearLayout>


             <LinearLayout
                   android:layout_width="wrap_content"
                   android:layout_height="wrap_content"
                   android:orientation="horizontal"
                   android:layout_marginTop="-10dp" 
                   android:layout_gravity="right">

                   <ImageButton
                       android:id="@+id/imageButtondl"
                       android:layout_width="50dip"
                       android:layout_height="50dip"                           
                       android:background="@drawable/logout"
                       android:contentDescription="Logout" />
               </LinearLayout>


            <ListView
            android:id="@+id/mylist"
            android:layout_width="match_parent"
            android:layout_height="0dp"            
            android:layout_weight="1"/>
            />

            <Button
            android:id="@+id/btn_static"
            android:layout_gravity="center"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="EDIT"/>
            </LinearLayout>

由于我们域中代理服务器的限制,我的模拟器未处于工作模式,因此无法获取日志。请帮帮我们

最后能够通过将其发送到邮件来获取堆栈跟踪

                java.lang.RuntimeException: Unable to start activity ComponentInfo{kvbank.kvb_ebook/kvbank.kvb_epassbook.dummy}: android.view.InflateException: Binary XML file line #8: Binary XML file line #8: Error inflating class <unknown>
            at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2946)
            at android.app.ActivityThread.startActivityNow(ActivityThread.java:2744)
            at android.app.LocalActivityManager.moveToState(LocalActivityManager.java:136)
            at android.app.LocalActivityManager.startActivity(LocalActivityManager.java:348)
            at android.widget.TabHost$IntentContentStrategy.getContentView(TabHost.java:769)
            at android.widget.TabHost.setCurrentTab(TabHost.java:423)
            at android.widget.TabHost.addTab(TabHost.java:233)
            at kvbank.kvb_epassbook.TabDemo.onCreate(TabDemo.java:87)
            at android.app.Activity.performCreate(Activity.java:6998)
            at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1230)
            at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2899)
            at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3046)
            at android.app.ActivityThread.-wrap11(Unknown Source:0)
            at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1688)
            at android.os.Handler.dispatchMessage(Handler.java:105)
            at android.os.Looper.loop(Looper.java:164)
            at android.app.ActivityThread.main(ActivityThread.java:6809)
            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 #8: Binary XML file line #8: Error inflating class <unknown>
            Caused by: android.view.InflateException: Binary XML file line #8: 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:647)
            at com.android.internal.policy.PhoneLayoutInflater.onCreateView(PhoneLayoutInflater.java:58)
            at android.view.LayoutInflater.onCreateView(LayoutInflater.java:720)
            at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:788)
            at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:730)
            at android.view.LayoutInflater.rInflate(LayoutInflater.java:863)
            at android.view.LayoutInflater.rInflateChildren(LayoutInflater.java:824)
            at android.view.LayoutInflater.inflate(LayoutInflater.java:515)
            at android.view.LayoutInflater.inflate(LayoutInflater.java:423)
            at android.view.LayoutInflater.inflate(LayoutInflater.java:374)
            at com.android.internal.policy.PhoneWindow.setContentView(PhoneWindow.java:432)
            at android.app.Activity.setContentView(Activity.java:2677)
            at kvbank.kvb_epassbook.dummy.onCreate(dummy.java:190)
            at android.app.Activity.performCreate(Activity.java:6998)
            at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1230)
            at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2899)
            at android.app.ActivityThread.startActivityNow(ActivityThread.java:2744)
            at android.app.LocalActivityManager.moveToState(LocalActivityManager.java:136)
            at android.app.LocalActivityManager.startActivity(LocalActivityManager.java:348)
            at android.widget.TabHost$IntentContentStrategy.getContentView(TabHost.java:769)
            at android.widget.TabHost.setCurrentTab(TabHost.java:423)
            at android.widget.TabHost.addTab(TabHost.java:233)
            at kvbank.kvb_epassbook.TabDemo.onCreate(TabDemo.java:87)
            at android.app.Activity.performCreate(Activity.java:6998)
            at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1230)
            at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2899)
            at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3046)
            at android.app.ActivityThread.-wrap11(Unknown Source:0)
            at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1688)
            at android.os.Handler.dispatchMessage(Handler.java:105)
            at android.os.Looper.loop(Looper.java:164)
            at android.app.ActivityThread.main(ActivityThread.java:6809)
            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: Failed to resolve attribute at index 6: TypedValue{t=0x2/d=0x101009b a=1}
            at android.content.res.TypedArray.getColorStateList(TypedArray.java:538)
            at android.widget.TextView.<init>(TextView.java:910)
            at android.widget.TextView.<init>(TextView.java:824)
            at android.widget.TextView.<init>(TextView.java:820)
            ... 37 more

   Issue got solved. I am using "android:theme="@android:style/Theme.Holo"" 
   for my dummy class in android manifest which is not defined. removing 
   this line solved my issue

1 个答案:

答案 0 :(得分:0)

正如您所说,您无法获取日志文件。我不太清楚这背后的原因。你可以试试这个。

1。/> myList 下方的xml中出现意外的文字Listview删除该部分

即使您可以使用Unexpected text found in file: "/>"在XML中看到警告始终检查您的XML警告是否为InflateClassException

  

布局资源文件应该只包含内容元素和属性。任何   在文件中找到的XML文本内容可能是偶然的。

(来自代表崩溃机会的警告信息。)

2。删除Numbers表单ID,因为ID通常在布局XML文件中以字符串形式分配。