Android Studio:我的所有 XML 文件都没有显示预览渲染

Android Studio: Preview rendering not appearing for all my XML files

自从我将 glide 依赖项添加到我的 gradle 文件夹中后,我所有的预览渲染都没有显示出来。我试过使 .ideas 文件失效、重建、同步甚至删除。我也删除了添加的 glide 依赖项。然而,仍然没有成功。请帮忙,谢谢!!!

部分错误:

java.lang.ArrayIndexOutOfBoundsException: 16
    at android.text.StaticLayout.generate(StaticLayout.java:854)
    at android.text.StaticLayout.<init>(StaticLayout.java:603)
    at android.text.StaticLayout.<init>(StaticLayout.java:50)
    at android.text.StaticLayout$Builder.build(StaticLayout.java:425)
    at android.widget.TextView.makeSingleLayout(TextView.java:8385)
    at android.widget.TextView.makeNewLayout(TextView.java:8204)
    at android.widget.TextView.onMeasure(TextView.java:8586)
    at android.view.View.measure_Original(View.java:23169)
    at android.view.View_Delegate.measure(View_Delegate.java:80)
    at android.view.View.measure(View.java:23133)
    at android.widget.RelativeLayout.measureChildHorizontal(RelativeLayout.java:715)
    at android.widget.RelativeLayout.onMeasure(RelativeLayout.java:461)
    at android.view.View.measure_Original(View.java:23169)
    at android.view.View_Delegate.measure(View_Delegate.java:80)
    at android.view.View.measure(View.java:23133)
    at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:6749)
    at android.widget.FrameLayout.onMeasure(FrameLayout.java:185)
    at android.view.View.measure_Original(View.java:23169)
    at android.view.View_Delegate.measure(View_Delegate.java:80)
    at android.view.View.measure(View.java:23133)
    at android.widget.RelativeLayout.measureChildHorizontal(RelativeLayout.java:715)
    at android.widget.RelativeLayout.onMeasure(RelativeLayout.java:461)
    at android.view.View.measure_Original(View.java:23169)
    at android.view.View_Delegate.measure(View_Delegate.java:80)
    at android.view.View.measure(View.java:23133)
    at com.android.layoutlib.bridge.impl.RenderSessionImpl.measureView(RenderSessionImpl.java:592)
    at com.android.layoutlib.bridge.impl.RenderSessionImpl.inflate(RenderSessionImpl.java:345)
    at com.android.layoutlib.bridge.Bridge.createSession(Bridge.java:386)
    at com.android.tools.idea.layoutlib.LayoutLibrary.createSession(LayoutLibrary.java:193)
    at com.android.tools.idea.rendering.RenderTask.createRenderSession(RenderTask.java:450)
    at com.android.tools.idea.rendering.RenderTask.lambda$inflate(RenderTask.java:590)
    at java.util.concurrent.FutureTask.run(FutureTask.java:266)
    at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
    at java.util.concurrent.FutureTask.run(FutureTask.java:266)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
    at java.lang.Thread.run(Thread.java:745)

2.

 java.lang.ArrayIndexOutOfBoundsException: 16
    at android.text.StaticLayout.generate(StaticLayout.java:854)
    at android.text.StaticLayout.<init>(StaticLayout.java:603)
    at android.text.StaticLayout.<init>(StaticLayout.java:50)
    at android.text.StaticLayout$Builder.build(StaticLayout.java:425)
    at android.widget.TextView.makeSingleLayout(TextView.java:8385)
    at android.widget.TextView.makeNewLayout(TextView.java:8204)
    at android.widget.TextView.onMeasure(TextView.java:8586)
    at androidx.appcompat.widget.AppCompatTextView.onMeasure_Original(AppCompatTextView.java:501)
    at androidx.appcompat.widget.AppCompatTextView.onMeasure(AppCompatTextView.java)
    at android.view.View.measure_Original(View.java:23169)
    at android.view.View_Delegate.measure(View_Delegate.java:80)
    at android.view.View.measure(View.java:23133)
    at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:6749)
    at android.widget.LinearLayout.measureChildBeforeLayout(LinearLayout.java:1535)
    at android.widget.LinearLayout.measureHorizontal(LinearLayout.java:1187)
    at android.widget.LinearLayout.onMeasure(LinearLayout.java:706)
    at android.view.View.measure_Original(View.java:23169)
    at android.view.View_Delegate.measure(View_Delegate.java:80)
    at android.view.View.measure(View.java:23133)
    at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:6749)
    at android.widget.FrameLayout.onMeasure(FrameLayout.java:185)
    at android.view.View.measure_Original(View.java:23169)
    at android.view.View_Delegate.measure(View_Delegate.java:80)
    at android.view.View.measure(View.java:23133)
    at android.widget.RelativeLayout.measureChildHorizontal(RelativeLayout.java:715)
    at android.widget.RelativeLayout.onMeasure(RelativeLayout.java:461)
    at android.view.View.measure_Original(View.java:23169)
    at android.view.View_Delegate.measure(View_Delegate.java:80)
    at android.view.View.measure(View.java:23133)
    at com.android.layoutlib.bridge.impl.RenderSessionImpl.measureView(RenderSessionImpl.java:592)
    at com.android.layoutlib.bridge.impl.RenderSessionImpl.inflate(RenderSessionImpl.java:345)
    at com.android.layoutlib.bridge.Bridge.createSession(Bridge.java:386)
    at com.android.tools.idea.layoutlib.LayoutLibrary.createSession(LayoutLibrary.java:193)
    at com.android.tools.idea.rendering.RenderTask.createRenderSession(RenderTask.java:450)
    at com.android.tools.idea.rendering.RenderTask.lambda$inflate(RenderTask.java:590)
    at java.util.concurrent.FutureTask.run(FutureTask.java:266)
    at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
    at java.util.concurrent.FutureTask.run(FutureTask.java:266)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
    at java.lang.Thread.run(Thread.java:745)
  1. 我的样式android:windowFullScreen也无法解析。

我仍然 运行 遇到一些渲染问题,尤其是那些使用 androidx 函数的问题。但是,在重新安装 android studio 后,我确实设法查看了大部分渲染图。希望对有需要的人有所帮助!

我遇到同样的 java.lang.ArrayIndexOutOfBoundsException 错误并尝试 运行 文件 > 使缓存无效,重新启动。它对我不起作用。

我的布局预览不会显示,因为我在布局文件中有错误。要解决此问题,尝试逐一注释掉布局 XML 文件中的每个组件。继续尝试,直到找出导致此错误的组件。

您的错误很可能是由 EditView 组件或其他文本相关组件引起的。