android studio布局显示异常或空白
程序员文章站
2022-05-31 10:56:14
...
今天在开发过程中遇到一个大问题,在切换到android studio布局页面的时候会出现白屏,无法显示出具体控件,但是当我切换到其他project的时候一切显示正常,比较蛋疼,先贴异常代码:
1、Failed to instantiate one or more classes
Rendering failed with a known bug. Please try a rebuild.
The following classes could not be instantiated:
- android.support.v7.widget.Toolbar (Open Class, Show Exception, Clear Cache)
- android.support.v7.internal.app.WindowDecorActionBar (Open Class, Show Exception, Clear Cache)
Tip: Use View.isInEditMode() in your custom views to skip code or show sample data when shown in the IDE. If this is an unexpected error you can also try to build the project, then manually refresh the layout. Exception Details java.lang.NoSuchFieldError: Toolbar_buttonGravity
at android.support.v7.widget.Toolbar.<init>(Toolbar.java:231)
at java.lang.reflect.Constructor.newInstance(Constructor.java:423)
at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:727)
at android.view.LayoutInflater.rInflate_Original(LayoutInflater.java:858)
at android.view.LayoutInflater_Delegate.rInflate(LayoutInflater_Delegate.java:70)
at android.view.LayoutInflater.rInflate(LayoutInflater.java:834)
at android.view.LayoutInflater.rInflateChildren(LayoutInflater.java:821)
at android.view.LayoutInflater.rInflate_Original(LayoutInflater.java:861)
at android.view.LayoutInflater_Delegate.rInflate(LayoutInflater_Delegate.java:70)
at android.view.LayoutInflater.rInflate(LayoutInflater.java:834)
at android.view.LayoutInflater.rInflateChildren(LayoutInflater.java:821)
at android.view.LayoutInflater.inflate(LayoutInflater.java:518)
at android.view.LayoutInflater.inflate(LayoutInflater.java:426)
at com.android.layoutlib.bridge.bars.BridgeActionBar.<init>(BridgeActionBar.java:84)
at com.android.layoutlib.bridge.bars.AppCompatActionBar.<init>(AppCompatActionBar.java:59)
at com.android.layoutlib.bridge.impl.Layout.createActionBar(Layout.java:241)
at com.android.layoutlib.bridge.impl.Layout.<init>(Layout.java:153) Copy stack to clipboard
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
- 11
- 12
- 13
- 14
- 15
- 16
- 17
- 18
- 19
- 20
- 21
- 22
2、can’t make a decor toolbar out of MockView
onMeasure error (Details)
Details:
java.lang.IllegalStateException: Can't make a decor toolbar out of MockView
at
android.support.v7.internal.widget.ActionBarOverlayLayout.getDecorToolbar(ActionBarOverlayLayout.java:542)
at
android.support.v7.internal.widget.ActionBarOverlayLayout.pullChildren(ActionBarOverlayLayout.java:532)
at
android.support.v7.internal.widget.ActionBarOverlayLayout.onMeasure_Original(ActionBarOverlayLayout.java:331)
at android.support.v7.internal.widget.ActionBarOverlayLayout.onMeasure(ActionBarOverlayLayout.java)
at android.view.View.measure(View.java:19734)
at android.widget.RelativeLayout.measureChildHorizontal(RelativeLayout.java:715)
at android.widget.RelativeLayout.onMeasure(RelativeLayout.java:461)
at android.view.View.measure(View.java:19734)
at com.android.layoutlib.bridge.impl.RenderSessionImpl.measureView(RenderSessionImpl.java:589)
at com.android.layoutlib.bridge.impl.RenderSessionImpl.inflate(RenderSessionImpl.java:342)
at com.android.layoutlib.bridge.Bridge.createSession(Bridge.java:429)
at com.android.ide.common.rendering.LayoutLibrary.createSession(LayoutLibrary.java:368)
at com.android.tools.idea.rendering.RenderTask$2.compute(RenderTask.java:567)
at com.android.tools.idea.rendering.RenderTask$2.compute(RenderTask.java:549)
at com.intellij.openapi.application.impl.ApplicationImpl.runReadAction(ApplicationImpl.java:863)
at com.android.tools.idea.rendering.RenderTask.createRenderSession(RenderTask.java:549)
at com.android.tools.idea.rendering.RenderTask.lambda$inflate$1(RenderTask.java:680)
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
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
- 11
- 12
- 13
- 14
- 15
- 16
- 17
- 18
- 19
- 20
- 21
- 22
- 23
- 24
- 25
Tip: Try to refresh the layout.
3、Render problem
Couldn't resolve resource @id/etView
- 1
Tip: Try to refresh the layout.
显示错误图
显示正确图
主要将上方红色框框内的AppThene调整为NoTitleBar即可。
推荐阅读
-
Android Studio升级到3.0 Terminal 中文显示异常解决
-
Android Studio升级到3.0 Terminal 中文显示异常解决
-
Android Studio下载更新Android SDK网络异常或无法下载
-
Android Studio 运行起来一片空白,不显示控件
-
Android Studio预览布局时显示ActionBarOverlayLayout
-
android studio布局显示异常或空白
-
Android Studio下载更新Android SDK网络异常或无法下载
-
Android Studio Layout中不能显示布局控件的问题
-
Android Studio开发之布局 ---- UI界面全屏显示