开发问题之android studio布局显示异常

今天在开发过程中遇到一个大问题,在切换到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.(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.(BridgeActionBar.java:84)   
at com.android.layoutlib.bridge.bars.AppCompatActionBar.(AppCompatActionBar.java:59)   
at com.android.layoutlib.bridge.impl.Layout.createActionBar(Layout.java:241)   
at com.android.layoutlib.bridge.impl.Layout.(Layout.java:153) Copy stack to clipboard

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)

Tip: Try to refresh the layout.

3、Render problem

Couldn't resolve resource @id/etView   

Tip: Try to refresh the layout.


遇到问题先百度了,不过百度一顿后无果,各种方法都试过一遍发现没效果,所以就只好求救google爸爸了,这不才把关键字搜上去马上出来一堆答案,虽说跟百度搜出来的一样,不过还是找了一番,最后找了一个总结的比较全面的答案:摸我(貌似是外网,需要科学上网)

总结的方法一个个试下来只有最后一个有效果,略蛋疼的就是每次只能手动切换了,不过至少不用看白屏了,还是很不错的。
贴上错误图跟显示正常的对比图:

显示错误图
开发问题之android studio布局显示异常_第1张图片


显示正确图
开发问题之android studio布局显示异常_第2张图片

你可能感兴趣的:(开发中常见问题)