gpt4 book ai didi

java - 无法找到 Inflate 异常的根本原因,可能修复吗?

转载 作者:太空宇宙 更新时间:2023-11-04 10:11:41 25 4
gpt4 key购买 nike

应用程序强制关闭并出现错误:

java.lang.RuntimeException: Unable to start activity ComponentInfo{com.xxx.xxxx/com.xxx.xxx.activity.ExamActivity}: android.view.InflateException: Binary XML file line #219: Error inflating class TextView

为了解决这个问题,我尝试了以下问题的解决方案:

但是,由于上述解决方案均无效,因此我提出另一个问题。

请让我知道我做错了什么导致上述错误:

这是 Activity 布局资源文件:

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#F7F7F7"
android:orientation="vertical"
tools:context=".activity.ExamActivity">

<android.support.v7.widget.Toolbar
android:id="@+id/tb_exam"
android:layout_width="match_parent"
android:layout_height="40dp"
android:layout_marginTop="1dp"
android:background="@drawable/bg_toolbar"
android:elevation="4dp"
android:minHeight="?attr/actionBarSize"
android:theme="?attr/actionBarTheme"
app:navigationIcon="@drawable/ic_navigation_back">

<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:adjustViewBounds="true"
android:src="@drawable/ic_zyus_logo" />
</android.support.v7.widget.Toolbar>

<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent">

<ScrollView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:scrollbarThumbVertical="@android:color/transparent">

<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">

<android.support.v7.widget.CardView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="20dp"
android:layout_marginEnd="15dp"
android:layout_marginStart="15dp"
android:layout_marginTop="20dp"
app:cardBackgroundColor="@android:color/white"
app:cardCornerRadius="20dp">

<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">

<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#292E42"
android:orientation="vertical"
android:padding="20dp">

<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">

<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_alignParentStart="true"
android:orientation="vertical">

<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:fontFamily="@font/montserrat"
android:text="1"
android:textColor="@android:color/white"
android:textSize="13sp" />

<TextView
android:id="@+id/tv_exam_name_exam"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:fontFamily="@font/montserrat"
android:text="Text Exam"
android:textColor="@android:color/white"
android:textSize="13sp" />

</LinearLayout>

<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_alignParentEnd="true"
android:orientation="vertical">

<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="end"
android:id="@+id/ln_suggestions_exam"
android:background="@drawable/bg_call_a_friend_exam"
android:orientation="horizontal">

<ImageButton
android:id="@+id/ib_call_friend_exam"
style="@style/Base.Widget.AppCompat.Button.Borderless"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginRight="3dp"
android:layout_marginStart="3dp"
android:adjustViewBounds="true"
app:srcCompat="@drawable/ic_call_call_a_frnd_exam" />

<ImageButton
android:id="@+id/ib_fifty_fifty_exam"
style="@style/Base.Widget.AppCompat.Button.Borderless"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginRight="3dp"
android:layout_marginStart="3dp"
android:adjustViewBounds="true"
app:srcCompat="@drawable/ic_fifty_fifty" />
</LinearLayout>

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

<TextView
android:id="@+id/tv_hint_time_left_exam"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:fontFamily="@font/montserrat"
android:text="Time Left :"
android:textColor="@android:color/white"
android:textSize="13sp" />

<TextView
android:id="@+id/tv_timer_exam"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_marginStart="3dp"
android:fontFamily="@font/montserrat"
android:text="00:00:02"
android:textColor="#FF0137"
android:textSize="13sp" />


</LinearLayout>
</LinearLayout>

</RelativeLayout>

<View
android:layout_width="match_parent"
android:layout_height="0.3dp"
android:layout_marginEnd="20dp"
android:layout_marginStart="20dp"
android:layout_marginTop="3dp"
android:background="@android:color/darker_gray" />

<TextView
android:id="@+id/tv_question_name_exam"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="8dp"
android:fontFamily="@font/montserrat"
android:minHeight="60dp"
android:text="Why is the speaker of portail important ?"
android:textColor="@android:color/white"
android:textSize="13sp" />

<ImageView
android:id="@+id/iv_question_image_exam"
android:layout_width="70dp"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:adjustViewBounds="true" />


</LinearLayout>

<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:animateLayoutChanges="true"
android:orientation="vertical">

<com.tnm.zyus.custom.HeightWrappingViewPager
android:id="@+id/viewpager_exam"
android:layout_width="match_parent"
android:layout_height="match_parent" />

<!--
<android.support.v4.view.ViewPager
android:id="@+id/viewpager_exam"
android:layout_width="match_parent"
android:layout_height="300dp" />
-->

<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_marginTop="15dp"
android:orientation="horizontal">

<TextView
android:id="@+id/tv_btn_first_exam"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_margin="3dp"
android:background="@drawable/btn_next_previous_exam"
android:drawablePadding="5dp"
android:drawableStart="@drawable/ic_arrow_double_left_exam"
android:fontFamily="@font/montserrat"
android:paddingBottom="5dp"
android:paddingEnd="10dp"
android:paddingStart="10dp"
android:paddingTop="5dp"
android:text="First"
android:textColor="@android:color/white"
android:textSize="11sp" />

<TextView
android:id="@+id/tv_btn_previous_exam"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_margin="3dp"
android:background="@drawable/btn_next_previous_exam"
android:drawablePadding="5dp"
android:drawableStart="@drawable/ic_arrow_left_exam"
android:fontFamily="@font/montserrat"
android:paddingBottom="5dp"
android:paddingEnd="10dp"
android:paddingStart="10dp"
android:paddingTop="5dp"
android:text="Previous"
android:textColor="@android:color/white"
android:textSize="11sp" />


<TextView
android:id="@+id/tv_question_number_exam"
android:layout_width="30dp"
android:layout_height="wrap_content"
android:layout_margin="3dp"
android:background="@drawable/btn_next_previous_exam"
android:fontFamily="@font/montserrat"
android:gravity="center"
android:paddingBottom="5dp"
android:paddingEnd="5dp"
android:paddingStart="5dp"
android:paddingTop="5dp"
android:text="10"
android:textColor="@android:color/white"
android:textSize="11sp" />



<TextView
android:id="@+id/tv_btn_next_exam"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_margin="3dp"
android:background="@drawable/btn_next_previous_exam"
android:drawablePadding="5dp"
android:drawableRight="@drawable/ic_arrow_right_exam"
android:fontFamily="@font/montserrat"
android:paddingBottom="5dp"
android:paddingEnd="10dp"
android:paddingStart="10dp"
android:paddingTop="5dp"
android:text="Next"
android:textColor="@android:color/white"
android:textSize="11sp" />

</LinearLayout>

<LinearLayout
android:id="@+id/ln_take_brake_exam"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_margin="30dp"
android:background="@drawable/btn_start_exam"
android:orientation="horizontal">

<TextView
android:id="@+id/tv_take_brake_exam"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_margin="10dp"
android:paddingStart="15dp"
android:text="Take a Brake"
android:textColor="@android:color/white"
android:textSize="16sp" />

<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_marginStart="5dp"
app:srcCompat="@drawable/ic_coffee" />
</LinearLayout>

<Button
android:id="@+id/btn_finish_exam"
android:layout_width="150dp"
android:layout_height="40dp"
android:layout_gravity="center"
android:layout_margin="30dp"
android:background="@drawable/btn_finish_exam"
android:text="Finish"
android:textAllCaps="false"
android:textColor="#0a870c"
android:visibility="gone" />

</LinearLayout>
</LinearLayout>
</android.support.v7.widget.CardView>
</LinearLayout>
</ScrollView>

<RelativeLayout
android:id="@+id/rl_loader_exam"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#F7F7F7"
android:visibility="gone">

<ProgressBar
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:layout_centerVertical="true" />
</RelativeLayout>
</RelativeLayout>

</LinearLayout>

什么可能导致此问题以及如何有效解决此问题?

这也是堆栈跟踪:

java.lang.RuntimeException: Unable to start activity ComponentInfo{com.tnm.zyus/com.tnm.zyus.activity.ExamActivity}: android.view.InflateException: Binary XML file line #219: Error inflating class TextView
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2441)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2500)
at android.app.ActivityThread.access$900(ActivityThread.java:171)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1309)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:146)
at android.app.ActivityThread.main(ActivityThread.java:5679)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:515)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1291)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1107)
at dalvik.system.NativeStart.main(Native Method)
Caused by: android.view.InflateException: Binary XML file line #219: Error inflating class TextView
at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:719)
at android.view.LayoutInflater.rInflate(LayoutInflater.java:761)
at android.view.LayoutInflater.rInflate(LayoutInflater.java:769)
at android.view.LayoutInflater.rInflate(LayoutInflater.java:769)
at android.view.LayoutInflater.rInflate(LayoutInflater.java:769)
at android.view.LayoutInflater.rInflate(LayoutInflater.java:769)
at android.view.LayoutInflater.rInflate(LayoutInflater.java:769)
at android.view.LayoutInflater.rInflate(LayoutInflater.java:769)
at android.view.LayoutInflater.rInflate(LayoutInflater.java:769)
at android.view.LayoutInflater.inflate(LayoutInflater.java:498)
at android.view.LayoutInflater.inflate(LayoutInflater.java:398)
at android.view.LayoutInflater.inflate(LayoutInflater.java:354)
at android.support.v7.app.AppCompatDelegateImplV9.setContentView(AppCompatDelegateImplV9.java:287)
at android.support.v7.app.AppCompatActivity.setContentView(AppCompatActivity.java:139)
at com.tnm.zyus.activity.ExamActivity.onCreate(ExamActivity.java:68)
at android.app.Activity.performCreate(Activity.java:5582)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1093)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2405)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2500) 
at android.app.ActivityThread.access$900(ActivityThread.java:171) 
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1309) 
at android.os.Handler.dispatchMessage(Handler.java:102) 
at android.os.Looper.loop(Looper.java:146) 
at android.app.ActivityThread.main(ActivityThread.java:5679) 
at java.lang.reflect.Method.invokeNative(Native Method) 
at java.lang.reflect.Method.invoke(Method.java:515) 
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1291) 
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1107) 
at dalvik.system.NativeStart.main(Native Method) 
Caused by: android.content.res.Resources$NotFoundException: File res/drawable/ic_arrow_double_left_exam.xml from drawable resource ID #0x7f0800b2
at android.content.res.Resources.loadDrawable(Resources.java:3439)
at android.content.res.TypedArray.getDrawable(TypedArray.java:602)
at android.widget.TextView.<init>(TextView.java:1335)
at android.support.v7.widget.AppCompatTextView.<init>(AppCompatTextView.java:76)
at android.support.v7.widget.AppCompatTextView.<init>(AppCompatTextView.java:72)
at android.support.v7.app.AppCompatViewInflater.createTextView(AppCompatViewInflater.java:176)
at android.support.v7.app.AppCompatViewInflater.createView(AppCompatViewInflater.java:101)
at android.support.v7.app.AppCompatDelegateImplV9.createView(AppCompatDelegateImplV9.java:1035)
at android.support.v7.app.AppCompatDelegateImplV9.onCreateView(AppCompatDelegateImplV9.java:1092)
at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:690)
at android.view.LayoutInflater.rInflate(LayoutInflater.java:761) 
at android.view.LayoutInflater.rInflate(LayoutInflater.java:769) 
at android.view.LayoutInflater.rInflate(LayoutInflater.java:769) 
at android.view.LayoutInflater.rInflate(LayoutInflater.java:769) 
at android.view.LayoutInflater.rInflate(LayoutInflater.java:769) 
at android.view.LayoutInflater.rInflate(LayoutInflater.java:769) 
at android.view.LayoutInflater.rInflate(LayoutInflater.java:769) 
at android.view.LayoutInflater.rInflate(LayoutInflater.java:769) 
at android.view.LayoutInflater.inflate(LayoutInflater.java:498) 
at android.view.LayoutInflater.inflate(LayoutInflater.java:398) 
at android.view.LayoutInflater.inflate(LayoutInflater.java:354) 
at android.support.v7.app.AppCompatDelegateImplV9.setContentView(AppCompatDelegateImplV9.java:287) 
at android.support.v7.app.AppCompatActivity.setContentView(AppCompatActivity.java:139) 
at com.tnm.zyus.activity.ExamActivity.onCreate(ExamActivity.java:68) 
at android.app.Activity.performCreate(Activity.java:5582) 
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1093) 
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2405) 
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2500) 
at android.app.ActivityThread.access$900(ActivityThread.java:171) 
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1309) 
at android.os.Handler.dispatchMessage(Handler.java:102) 
at android.os.Looper.loop(Looper.java:146) 
at android.app.ActivityThread.main(ActivityThread.java:5679) 
at java.lang.reflect.Method.invokeNative(Native Method) 
at java.lang.reflect.Method.invoke(Method.java:515) 
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1291) 
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1107) 
at dalvik.system.NativeStart.main(Native Method) 
Caused by: org.xmlpull.v1.XmlPullParserException: Binary XML file line #2: invalid drawable tag vector
at android.graphics.drawable.Drawable.createFromXmlInner(Drawable.java:986)
at android.graphics.drawable.Drawable.createFromXml(Drawable.java:930)
at android.content.res.Resources.loadDrawable(Resources.java:3435)
at android.content.res.TypedArray.getDrawable(TypedArray.java:602) 
at android.widget.TextView.<init>

最佳答案

检查@drawable/ic_arrow_double_left_exam 文件是否存在或尝试清理并重建。

Caused by: android.content.res.Resources$NotFoundException: File res/drawable/ic_arrow_double_left_exam.xml from drawable resource ID #0x7f0800b2

关于java - 无法找到 Inflate 异常的根本原因,可能修复吗?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/52226531/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com