应用程序力关闭时出错:
JAVAlang.RuntimeException:无法启动活动组件信息{com.xxx.xxxx/com.xxx.xxx.activity.ExamActivity}:android。看法充气异常:二进制XML文件行#219:充气类TextView时出错
为了解决这个问题,我尝试了以下问题的解决方案:
然而,由于上述解决方案都不起作用,我现在提出另一个问题。
请让我知道我做错了什么导致了上述错误:
以下是活动布局资源文件:
<?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>
这可能是什么原因造成的?如何有效解决?
以下是stacktrace:
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\u arrow\u double\u left\u exam
文件是否存在,或尝试清理和重建。
Caused by: android.content.res.Resources$NotFoundException: File res/drawable/ic_arrow_double_left_exam.xml from drawable resource ID #0x7f0800b2
问题内容: 我发现了Java中的方法: 此方法的来源可用吗?也许在OpenJDK中? 问题答案: 来自jdk / src / share / native / java / lang / Object.c 表示其为函数指针(可能已完成,因此他们可以实现特定于平台的本机代码) 为JVM_Clone执行grep会产生以下结果: (从hotspot / src / share / vm / prims
我对Scanner有一个问题,因为它似乎采用输入值类型并强制用户下次输入值为相同类型。我找不到此代码不起作用的任何原因,并给我一个InputMismatchException,因为我已经编写了一百万次这样的代码并且没有问题。 这个问题不仅仅是register()方法的问题,而是整个程序的问题,例如下面的代码: 如果其中一种方法(如 register)要求用户输入字符串,则 int user=inp
问题内容: 我有这个小代码,用于将我的jsp连接到我的mysql数据库。 我已将连接器添加到我的构建路径中: 但我仍然收到此错误: java.lang.ClassNotFoundException:com.mysql.jdbc.Driver 有人可以帮我吗? 问题答案: 构建路径用于编译目的(假设您没有将mysql连接器jar包含在软件包中的代码)。 如果这是Web应用程序,请将其添加到lib文件
本文向大家介绍什么是OutOfMemoryError以及查找Java中OOM根本原因的步骤?,包括了什么是OutOfMemoryError以及查找Java中OOM根本原因的步骤?的使用技巧和注意事项,需要的朋友参考一下 该OutOfMemoryError异常 被抛出JVM,当JVM没有足够的可用内存,来分配。OutOfMemoryError 在Exception 类层次结构中属于E rror类别。
问题内容: 我正在编写一些JUnit测试,以验证是否抛出了类型异常。但是,此异常多次包装在其他异常中,例如InvocationTargetException中,而InvocationTargetException又包装在RuntimeException中。 确定MyCustomException是否导致我实际捕获的异常的最佳方法是什么?我想做这样的事情(见下划线): 我想避免称呼一些“层”较深的类