Android - 膨胀文本视图时出错

Posted

技术标签:

【中文标题】Android - 膨胀文本视图时出错【英文标题】:Android - Error inflating text view 【发布时间】:2017-07-25 01:46:14 【问题描述】:

我知道 *** 上有很多类似的问题。 但是这些都不能解决我的问题。

这与主题设置或未找到资源无关。 而且我没有在这个布局中加载大图像(所有背景都来自可绘制的 xml)。 所有属性都有准确的值,包括命名空间声明。 它只是随机抛出这个异常。 看起来像一个android bug。

它发生在 Nexus 5X、Nexus 6P、HTC_A9u、ASUS_Z012 等。 我正在使用 API 25,支持库 25.0.1,构建工具 25.0.2。

在我更改为使用 API 25 后,它开始报告此异常。

布局中有 20 个相似的节点,ScrollViewFragment 持有这种布局。 我用片段事务初始化它,然后把它放在DrawerLayout中。

布局节点:

<ScrollView
    android:id="@+id/mainMenuScrollView"
    android:layout_
    android:layout_
    android:paddingBottom="10dp">

    <RelativeLayout
        android:layout_
        android:layout_>

        ...

        <RelativeLayout
            android:id="@+id/aboutHolder"
            android:layout_
            android:layout_
            android:layout_marginTop="5dp"
            android:paddingTop="7dp"
            android:paddingBottom="7dp"
            android:paddingStart="10dp"
            android:paddingEnd="5dp"
            android:clickable="true"
            android:background="?theme.mainMenuItemBackground"
            android:layout_below="@+id/otherHolder">
            <TextView
                    android:id="@+id/aboutCapital"
                    android:layout_
                    android:layout_
                    android:layout_centerVertical="true"
                    android:background="@drawable/my_background"
                    android:gravity="center"
                    android:textSize="14sp"
                    android:textColor="?theme.titleColor"
                    android:text="A"/>
            <TextView
                    android:id="@+id/aboutName"
                    android:layout_
                    android:layout_
                    android:layout_centerVertical="true"
                    android:layout_marginStart="10dp"
                    android:layout_toEndOf="@+id/aboutCapital"
                    android:textStyle="bold"
                    android:textSize="@dimen/menu_item_title"
                    android:textColor="?theme.titleColor"
                    android:text="About"/>
        </RelativeLayout>

        ...

    </RelativeLayout>

</ScrollView>

它也发生在ScrollView 或类似&lt;unknown&gt; 的地方。

错误日志(TextView):

Exception java.lang.RuntimeException: Unable to start activity ComponentInfocom.example.myapp/com.example.myapp.LauncherActivity: android.view.InflateException: Binary XML file line #813: Binary XML file line #813: Error inflating class TextView
android.app.ActivityThread.performLaunchActivity (ActivityThread.java:2665)
android.app.ActivityThread.handleLaunchActivity (ActivityThread.java:2726)
android.app.ActivityThread.-wrap12 (ActivityThread.java)
android.app.ActivityThread$H.handleMessage (ActivityThread.java:1477)
android.os.Handler.dispatchMessage (Handler.java:102)
android.os.Looper.loop (Looper.java:154)
android.app.ActivityThread.main (ActivityThread.java:6119)
java.lang.reflect.Method.invoke (Method.java)
com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run (ZygoteInit.java:886)
com.android.internal.os.ZygoteInit.main (ZygoteInit.java:776)

Caused by android.view.InflateException: Binary XML file line #813: Binary XML file line #813: Error inflating class TextView

Caused by android.view.InflateException: Binary XML file line #813: Error inflating class TextView

Caused by java.lang.NullPointerException: Attempt to invoke virtual method 'java.lang.CharSequence android.content.res.StringBlock.get(int)' on a null object reference
android.content.res.AssetManager.getPooledStringForCookie (AssetManager.java:306)
android.content.res.TypedArray.loadStringValueAt (TypedArray.java:1217)
android.content.res.TypedArray.getValueAt (TypedArray.java:1203)
android.content.res.TypedArray.getColorStateList (TypedArray.java:526)
android.widget.TextView.<init> (TextView.java:1080)
android.widget.TextView.<init> (TextView.java:704)
android.support.v7.widget.AppCompatTextView.<init> (AppCompatTextView.java:62)
android.support.v7.widget.AppCompatTextView.<init> (AppCompatTextView.java:58)
android.support.v7.app.AppCompatViewInflater.createView (AppCompatViewInflater.java:103)
android.support.v7.app.AppCompatDelegateImplV9.createView (AppCompatDelegateImplV9.java:1017)
android.support.v7.app.AppCompatDelegateImplV9.onCreateView (AppCompatDelegateImplV9.java:1076)
android.support.v4.view.LayoutInflaterCompatHC$FactoryWrapperHC.onCreateView (LayoutInflaterCompatHC.java:44)
android.view.LayoutInflater$FactoryMerger.onCreateView (LayoutInflater.java:192)
android.view.LayoutInflater.createViewFromTag (LayoutInflater.java:769)
android.view.LayoutInflater.createViewFromTag (LayoutInflater.java:727)
android.view.LayoutInflater.rInflate (LayoutInflater.java:858)
android.view.LayoutInflater.rInflateChildren (LayoutInflater.java:821)
android.view.LayoutInflater.rInflate (LayoutInflater.java:861)
android.view.LayoutInflater.rInflateChildren (LayoutInflater.java:821)
android.view.LayoutInflater.rInflate (LayoutInflater.java:861)
android.view.LayoutInflater.rInflateChildren (LayoutInflater.java:821)
android.view.LayoutInflater.rInflate (LayoutInflater.java:861)
android.view.LayoutInflater.rInflateChildren (LayoutInflater.java:821)
android.view.LayoutInflater.inflate (LayoutInflater.java:518)
android.view.LayoutInflater.inflate (LayoutInflater.java:426)
com.example.myapp.MainMenuFragment.onCreateView (MainMenuFragment.java:306)
android.support.v4.app.Fragment.performCreateView (Fragment.java:2087)
android.support.v4.app.FragmentManagerImpl.moveToState (FragmentManagerImpl.java:1113)
android.support.v4.app.FragmentManagerImpl.moveToState (FragmentManagerImpl.java:1295)
android.support.v4.app.FragmentManagerImpl.moveToState (FragmentManagerImpl.java:1277)
android.support.v4.app.FragmentManagerImpl.dispatchActivityCreated (FragmentManagerImpl.java:2154)
android.support.v4.app.FragmentController.dispatchActivityCreated (FragmentController.java:201)
android.support.v4.app.FragmentActivity.onStart (FragmentActivity.java:603)
android.support.v7.app.AppCompatActivity.onStart (AppCompatActivity.java:181)
com.example.myapp.LauncherActivity.onStart (LauncherActivity.java:2193)
android.app.Instrumentation.callActivityOnStart (Instrumentation.java:1248)
android.app.Activity.performStart (Activity.java:6696)
android.app.ActivityThread.performLaunchActivity (ActivityThread.java:2628)
android.app.ActivityThread.handleLaunchActivity (ActivityThread.java:2726)
android.app.ActivityThread.-wrap12 (ActivityThread.java)
android.app.ActivityThread$H.handleMessage (ActivityThread.java:1477)
android.os.Handler.dispatchMessage (Handler.java:102)
android.os.Looper.loop (Looper.java:154)
android.app.ActivityThread.main (ActivityThread.java:6119)
java.lang.reflect.Method.invoke (Method.java)
com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run (ZygoteInit.java:886)
com.android.internal.os.ZygoteInit.main (ZygoteInit.java:776)

错误日志(&lt;unknown&gt;)

Exception java.lang.RuntimeException: Unable to start activity ComponentInfocom.example.myapp/com.example.myapp.LauncherActivity: android.view.InflateException: Binary XML file line #1051: Binary XML file line #1051: Error inflating class <unknown>
android.app.ActivityThread.performLaunchActivity (ActivityThread.java:2666)
android.app.ActivityThread.handleLaunchActivity (ActivityThread.java:2727)
android.app.ActivityThread.-wrap12 (ActivityThread.java)
android.app.ActivityThread$H.handleMessage (ActivityThread.java:1478)
android.os.Handler.dispatchMessage (Handler.java:102)
android.os.Looper.loop (Looper.java:154)
android.app.ActivityThread.main (ActivityThread.java:6121)
java.lang.reflect.Method.invoke (Method.java)
com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run (ZygoteInit.java:876)
com.android.internal.os.ZygoteInit.main (ZygoteInit.java:766)

Caused by android.view.InflateException: Binary XML file line #1051: Binary XML file line #1051: Error inflating class <unknown>

Caused by android.view.InflateException: Binary XML file line #1051: Error inflating class <unknown>

Caused by java.lang.reflect.InvocationTargetException:
java.lang.reflect.Constructor.newInstance0 (Constructor.java)
java.lang.reflect.Constructor.newInstance (Constructor.java:430)
android.view.LayoutInflater.createView (LayoutInflater.java:645)
com.android.internal.policy.PhoneLayoutInflater.onCreateView (PhoneLayoutInflater.java:58)
android.view.LayoutInflater.onCreateView (LayoutInflater.java:717)
android.view.LayoutInflater.createViewFromTag (LayoutInflater.java:785)
android.view.LayoutInflater.createViewFromTag (LayoutInflater.java:727)
android.view.LayoutInflater.rInflate (LayoutInflater.java:858)
android.view.LayoutInflater.rInflateChildren (LayoutInflater.java:821)
android.view.LayoutInflater.rInflate (LayoutInflater.java:861)
android.view.LayoutInflater.rInflateChildren (LayoutInflater.java:821)
android.view.LayoutInflater.rInflate (LayoutInflater.java:861)
android.view.LayoutInflater.rInflateChildren (LayoutInflater.java:821)
android.view.LayoutInflater.rInflate (LayoutInflater.java:861)
android.view.LayoutInflater.rInflateChildren (LayoutInflater.java:821)
android.view.LayoutInflater.inflate (LayoutInflater.java:518)
android.view.LayoutInflater.inflate (LayoutInflater.java:426)
com.example.myapp.MainMenuFragment.onCreateView (MainMenuFragment.java:306)
android.support.v4.app.Fragment.performCreateView (Fragment.java:2087)
android.support.v4.app.FragmentManagerImpl.moveToState (FragmentManagerImpl.java:1113)
android.support.v4.app.FragmentManagerImpl.moveToState (FragmentManagerImpl.java:1295)
android.support.v4.app.FragmentManagerImpl.moveToState (FragmentManagerImpl.java:1277)
android.support.v4.app.FragmentManagerImpl.dispatchActivityCreated (FragmentManagerImpl.java:2154)
android.support.v4.app.FragmentController.dispatchActivityCreated (FragmentController.java:201)
android.support.v4.app.FragmentActivity.onStart (FragmentActivity.java:603)
android.support.v7.app.AppCompatActivity.onStart (AppCompatActivity.java:181)
com.example.myapp.LauncherActivity.onStart (LauncherActivity.java:2193)
android.app.Instrumentation.callActivityOnStart (Instrumentation.java:1248)
android.app.Activity.performStart (Activity.java:6699)
android.app.ActivityThread.performLaunchActivity (ActivityThread.java:2629)
android.app.ActivityThread.handleLaunchActivity (ActivityThread.java:2727)
android.app.ActivityThread.-wrap12 (ActivityThread.java)
android.app.ActivityThread$H.handleMessage (ActivityThread.java:1478)
android.os.Handler.dispatchMessage (Handler.java:102)
android.os.Looper.loop (Looper.java:154)
android.app.ActivityThread.main (ActivityThread.java:6121)
java.lang.reflect.Method.invoke (Method.java)
com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run (ZygoteInit.java:876)
com.android.internal.os.ZygoteInit.main (ZygoteInit.java:766)

Caused by java.lang.NullPointerException: Attempt to invoke virtual method 'java.lang.CharSequence android.content.res.StringBlock.get(int)' on a null object reference
android.content.res.AssetManager.getPooledStringForCookie (AssetManager.java:306)
android.content.res.TypedArray.loadStringValueAt (TypedArray.java:1217)
android.content.res.TypedArray.getValueAt (TypedArray.java:1203)
android.content.res.TypedArray.getDrawable (TypedArray.java:923)
android.view.View.<init> (View.java:4202)
android.view.ViewGroup.<init> (ViewGroup.java:579)
android.widget.RelativeLayout.<init> (RelativeLayout.java:248)
android.widget.RelativeLayout.<init> (RelativeLayout.java:244)
android.widget.RelativeLayout.<init> (RelativeLayout.java:240)
java.lang.reflect.Constructor.newInstance0 (Constructor.java)
java.lang.reflect.Constructor.newInstance (Constructor.java:430)
android.view.LayoutInflater.createView (LayoutInflater.java:645)
com.android.internal.policy.PhoneLayoutInflater.onCreateView (PhoneLayoutInflater.java:58)
android.view.LayoutInflater.onCreateView (LayoutInflater.java:717)
android.view.LayoutInflater.createViewFromTag (LayoutInflater.java:785)
android.view.LayoutInflater.createViewFromTag (LayoutInflater.java:727)
android.view.LayoutInflater.rInflate (LayoutInflater.java:858)
android.view.LayoutInflater.rInflateChildren (LayoutInflater.java:821)
android.view.LayoutInflater.rInflate (LayoutInflater.java:861)
android.view.LayoutInflater.rInflateChildren (LayoutInflater.java:821)
android.view.LayoutInflater.rInflate (LayoutInflater.java:861)
android.view.LayoutInflater.rInflateChildren (LayoutInflater.java:821)
android.view.LayoutInflater.rInflate (LayoutInflater.java:861)
android.view.LayoutInflater.rInflateChildren (LayoutInflater.java:821)
android.view.LayoutInflater.inflate (LayoutInflater.java:518)
android.view.LayoutInflater.inflate (LayoutInflater.java:426)
com.example.myapp.MainMenuFragment.onCreateView (MainMenuFragment.java:306)
android.support.v4.app.Fragment.performCreateView (Fragment.java:2087)
android.support.v4.app.FragmentManagerImpl.moveToState (FragmentManagerImpl.java:1113)
android.support.v4.app.FragmentManagerImpl.moveToState (FragmentManagerImpl.java:1295)
android.support.v4.app.FragmentManagerImpl.moveToState (FragmentManagerImpl.java:1277)
android.support.v4.app.FragmentManagerImpl.dispatchActivityCreated (FragmentManagerImpl.java:2154)
android.support.v4.app.FragmentController.dispatchActivityCreated (FragmentController.java:201)
android.support.v4.app.FragmentActivity.onStart (FragmentActivity.java:603)
android.support.v7.app.AppCompatActivity.onStart (AppCompatActivity.java:181)
com.example.myapp.LauncherActivity.onStart (LauncherActivity.java:2193)
android.app.Instrumentation.callActivityOnStart (Instrumentation.java:1248)
android.app.Activity.performStart (Activity.java:6699)
android.app.ActivityThread.performLaunchActivity (ActivityThread.java:2629)
android.app.ActivityThread.handleLaunchActivity (ActivityThread.java:2727)
android.app.ActivityThread.-wrap12 (ActivityThread.java)
android.app.ActivityThread$H.handleMessage (ActivityThread.java:1478)
android.os.Handler.dispatchMessage (Handler.java:102)
android.os.Looper.loop (Looper.java:154)
android.app.ActivityThread.main (ActivityThread.java:6121)
java.lang.reflect.Method.invoke (Method.java)
com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run (ZygoteInit.java:876)
com.android.internal.os.ZygoteInit.main (ZygoteInit.java:766)

错误日志(ScrollView):

Exception java.lang.RuntimeException: Unable to start activity ComponentInfocom.example.myapp/com.example.myapp.LauncherActivity: android.view.InflateException: Binary XML file line #13: Binary XML file line #13: Error inflating class android.widget.ScrollView
android.app.ActivityThread.performLaunchActivity (ActivityThread.java:2665)
android.app.ActivityThread.handleLaunchActivity (ActivityThread.java:2726)
android.app.ActivityThread.-wrap12 (ActivityThread.java)
android.app.ActivityThread$H.handleMessage (ActivityThread.java:1477)
android.os.Handler.dispatchMessage (Handler.java:102)
android.os.Looper.loop (Looper.java:154)
android.app.ActivityThread.main (ActivityThread.java:6119)
java.lang.reflect.Method.invoke (Method.java)
com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run (ZygoteInit.java:886)
com.android.internal.os.ZygoteInit.main (ZygoteInit.java:776)

Caused by android.view.InflateException: Binary XML file line #13: Binary XML file line #13: Error inflating class android.widget.ScrollView

Caused by android.view.InflateException: Binary XML file line #13: Error inflating class android.widget.ScrollView

Caused by java.lang.reflect.InvocationTargetException:
java.lang.reflect.Constructor.newInstance0 (Constructor.java)
java.lang.reflect.Constructor.newInstance (Constructor.java:430)
android.view.LayoutInflater.createView (LayoutInflater.java:645)
com.android.internal.policy.PhoneLayoutInflater.onCreateView (PhoneLayoutInflater.java:58)
android.view.LayoutInflater.onCreateView (LayoutInflater.java:717)
android.view.LayoutInflater.createViewFromTag (LayoutInflater.java:785)
android.view.LayoutInflater.createViewFromTag (LayoutInflater.java:727)
android.view.LayoutInflater.rInflate (LayoutInflater.java:858)
android.view.LayoutInflater.rInflateChildren (LayoutInflater.java:821)
android.view.LayoutInflater.inflate (LayoutInflater.java:518)
android.view.LayoutInflater.inflate (LayoutInflater.java:426)
com.example.myapp.MainMenuFragment.onCreateView (MainMenuFragment.java:288)
android.support.v4.app.Fragment.performCreateView (Fragment.java:2087)
android.support.v4.app.FragmentManagerImpl.moveToState (FragmentManagerImpl.java:1113)
android.support.v4.app.FragmentManagerImpl.moveToState (FragmentManagerImpl.java:1295)
android.support.v4.app.FragmentManagerImpl.moveToState (FragmentManagerImpl.java:1277)
android.support.v4.app.FragmentManagerImpl.dispatchActivityCreated (FragmentManagerImpl.java:2154)
android.support.v4.app.FragmentController.dispatchActivityCreated (FragmentController.java:201)
android.support.v4.app.FragmentActivity.onStart (FragmentActivity.java:603)
android.support.v7.app.AppCompatActivity.onStart (AppCompatActivity.java:181)
com.example.myapp.LauncherActivity.onStart (LauncherActivity.java:2196)
android.app.Instrumentation.callActivityOnStart (Instrumentation.java:1248)
android.app.Activity.performStart (Activity.java:6696)
android.app.ActivityThread.performLaunchActivity (ActivityThread.java:2628)
android.app.ActivityThread.handleLaunchActivity (ActivityThread.java:2726)
android.app.ActivityThread.-wrap12 (ActivityThread.java)
android.app.ActivityThread$H.handleMessage (ActivityThread.java:1477)
android.os.Handler.dispatchMessage (Handler.java:102)
android.os.Looper.loop (Looper.java:154)
android.app.ActivityThread.main (ActivityThread.java:6119)
java.lang.reflect.Method.invoke (Method.java)
com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run (ZygoteInit.java:886)
com.android.internal.os.ZygoteInit.main (ZygoteInit.java:776)

Caused by java.lang.NullPointerException: Attempt to invoke virtual method 'java.lang.CharSequence android.content.res.StringBlock.get(int)' on a null object reference
android.content.res.AssetManager.getPooledStringForCookie (AssetManager.java:306)
android.content.res.TypedArray.loadStringValueAt (TypedArray.java:1217)
android.content.res.TypedArray.getValueAt (TypedArray.java:1203)
android.content.res.TypedArray.getDrawable (TypedArray.java:923)
android.view.View.initializeScrollbarsInternal (View.java:5133)
android.view.View.<init> (View.java:4660)
android.view.ViewGroup.<init> (ViewGroup.java:579)
android.widget.FrameLayout.<init> (FrameLayout.java:92)
android.widget.ScrollView.<init> (ScrollView.java:180)
android.widget.ScrollView.<init> (ScrollView.java:176)
android.widget.ScrollView.<init> (ScrollView.java:172)
java.lang.reflect.Constructor.newInstance0 (Constructor.java)
java.lang.reflect.Constructor.newInstance (Constructor.java:430)
android.view.LayoutInflater.createView (LayoutInflater.java:645)
com.android.internal.policy.PhoneLayoutInflater.onCreateView (PhoneLayoutInflater.java:58)
android.view.LayoutInflater.onCreateView (LayoutInflater.java:717)
android.view.LayoutInflater.createViewFromTag (LayoutInflater.java:785)
android.view.LayoutInflater.createViewFromTag (LayoutInflater.java:727)
android.view.LayoutInflater.rInflate (LayoutInflater.java:858)
android.view.LayoutInflater.rInflateChildren (LayoutInflater.java:821)
android.view.LayoutInflater.inflate (LayoutInflater.java:518)
android.view.LayoutInflater.inflate (LayoutInflater.java:426)
com.example.myapp.MainMenuFragment.onCreateView (MainMenuFragment.java:288)
android.support.v4.app.Fragment.performCreateView (Fragment.java:2087)
android.support.v4.app.FragmentManagerImpl.moveToState (FragmentManagerImpl.java:1113)
android.support.v4.app.FragmentManagerImpl.moveToState (FragmentManagerImpl.java:1295)
android.support.v4.app.FragmentManagerImpl.moveToState (FragmentManagerImpl.java:1277)
android.support.v4.app.FragmentManagerImpl.dispatchActivityCreated (FragmentManagerImpl.java:2154)
android.support.v4.app.FragmentController.dispatchActivityCreated (FragmentController.java:201)
android.support.v4.app.FragmentActivity.onStart (FragmentActivity.java:603)
android.support.v7.app.AppCompatActivity.onStart (AppCompatActivity.java:181)
com.example.myapp.LauncherActivity.onStart (LauncherActivity.java:2196)
android.app.Instrumentation.callActivityOnStart (Instrumentation.java:1248)
android.app.Activity.performStart (Activity.java:6696)
android.app.ActivityThread.performLaunchActivity (ActivityThread.java:2628)
android.app.ActivityThread.handleLaunchActivity (ActivityThread.java:2726)
android.app.ActivityThread.-wrap12 (ActivityThread.java)
android.app.ActivityThread$H.handleMessage (ActivityThread.java:1477)
android.os.Handler.dispatchMessage (Handler.java:102)
android.os.Looper.loop (Looper.java:154)
android.app.ActivityThread.main (ActivityThread.java:6119)
java.lang.reflect.Method.invoke (Method.java)
com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run (ZygoteInit.java:886)
com.android.internal.os.ZygoteInit.main (ZygoteInit.java:776)

【问题讨论】:

对我来说同样的问题。这是我的布局中的一个随机 TextView 导致的。它没有什么不同或特别之处。你找到工作了吗? 不,我没有。但是在我把setTheme(R.style.AppTheme);放在super.onCreate(savedInstanceState);之前,它会变得更好根据这个文件developer.android.com/topic/performance/launch-time.html 【参考方案1】:

我认为你的问题是:

android:textColor="?theme.titleColor"

你应该更改为@color/yourcolor 或十六进制颜色

【讨论】:

我有不同的主题设置。他们都使用不同的颜色。为什么你认为这是问题所在? 你试试我的回答吗?你能发布你的?theme.titleColor吗? 我无法尝试您的答案,因为我正在使用主题来应用所有颜色、背景等。&lt;item name="theme.titleColor"&gt;@color/list_item_title_color&lt;/item&gt; 你为什么不用@color/list_item_title_color???如果没有错误,您的代码在android:textColor="?theme.titleColor" 处出错 因为不同的主题使用不同的颜色。正如我所说,它也发生在 ScrollView 或类似 的东西上,而且并非每次都发生。所以我认为我是否选择使用@color/list_item_title_color 并不重要。说真的,?theme.titleColor 有什么问题?

以上是关于Android - 膨胀文本视图时出错的主要内容,如果未能解决你的问题,请参考以下文章

膨胀类 ImageView 时出错 - android.view.InflateException:二进制 XML 文件第 10 行:膨胀类 ImageView 时出错

使用 Android 膨胀类片段时出错

加载 webview 时膨胀类 android.webkit.WebView 时出错

膨胀类 android.widget.listview 时出错

在Android中膨胀类按钮时出错

Android:在drawerlayout中使用地图膨胀片段时出错