Android TextView.setText在Oreo中设置长文本时提供IndexOutOfBoundException

Android TextView.setText在Oreo中设置长文本时提供IndexOutOfBoundException,android,Android,我使用setText从字符串资源文件中设置了一个长字符串: W/ResourceType: Bad string block: string #968 is not null-terminated CREATING STRING CACHE OF 43224 bytes Bad string block: string #968 decoded length is not correct -1 vs 23209 W/System.e

我使用setText从字符串资源文件中设置了一个长字符串:

W/ResourceType: Bad string block: string #968 is not null-terminated
                CREATING STRING CACHE OF 43224 bytes
                Bad string block: string #968 decoded length is not correct -1 vs 23209
W/System.err: java.lang.IndexOutOfBoundsException
                  at android.content.res.StringBlock.nativeGetString(Native Method)
                  at android.content.res.StringBlock.get(StringBlock.java:82)
                  at android.content.res.AssetManager.getResourceValue(AssetManager.java:236)
W/System.err:     at android.content.res.AssetManager.getResourceText(AssetManager.java:164)
                  at android.content.res.Resources.getText(Resources.java:334)
                  at android.widget.TextView.setText(TextView.java:5494)
                  at com.test.test.activities.QTestActivity.onCreate(TestDetailsActivity.java:92)
                  at android.app.Activity.performCreate(Activity.java:6975)
                  at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1214)
                  at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2784)
W/System.err:     at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2906)
                  at android.app.ActivityThread.-wrap11(Unknown Source:0)
                  at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1605)
                  at android.os.Handler.dispatchMessage(Handler.java:105)
                  at android.os.Looper.loop(Looper.java:172)
                  at android.app.ActivityThread.main(ActivityThread.java:6637)
                  at java.lang.reflect.Method.invoke(Native Method)
W/System.err:     at com.android.internal.os.Zygote$MethodAndArgsCaller.run(Zygote.java:240)
                  at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:767)
这是xml文件:

<?xml version="1.0" encoding="utf-8"?>
<android.support.design.widget.CoordinatorLayout
    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:keepScreenOn="true">

    <android.support.v4.widget.NestedScrollView
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:clipToPadding="false"
        android:paddingBottom="10dp"
        android:paddingLeft="4dp"
        android:paddingRight="4dp"
        android:scrollbars="vertical"
        app:layout_behavior="@string/appbar_scrolling_view_behavior">

        <LinearLayout
            android:id="@+id/v_container"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:clickable="true"
            android:orientation="vertical">

            <ImageView
                android:id="@+id/iv_background"
                android:layout_width="match_parent"
                android:layout_height="70dp"
                android:clickable="false"
                android:contentDescription="@null"
                android:scaleType="centerInside"
                android:src="@drawable/header_bg"/>

            <TextView
                android:id="@+id/tv_text"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:clickable="false"
                android:gravity="center"
                android:textColor="@android:color/black"
                android:textSize="24sp"
                tools:ignore="RtlHardcoded"/>
        </LinearLayout>
    </android.support.v4.widget.NestedScrollView>


</android.support.design.widget.CoordinatorLayout>
我以前没有遇到任何问题,我将Android studio和Google play服务更新为最新版本:15.0.0,现在我面临这个问题

有解决方法吗?

尝试使用

mTextSample.setText(Html.fromHtml(text))

例如:

String text = "This is <font color='red'>simple</font>.";
textView.setText(Html.fromHtml(text), TextView.BufferType.SPANNABLE);
String text=“这很简单。”;
textView.setText(Html.fromHtml(text),textView.BufferType.SPANNABLE);

确保android profiler已关闭。它已关闭@DeepNaikIs有没有可能溢出一些内容?
String text = "This is <font color='red'>simple</font>.";
textView.setText(Html.fromHtml(text), TextView.BufferType.SPANNABLE);
 textView.setText(Html.fromHtml(getResources().getString(R.string.app_text), Html.FROM_HTML_MODE_LEGACY));