XML 预览中的渲染问题:无法定位模式 0
Rendering issue in XML preview : Unable to locate mode 0
更新后 android studio 在渲染过程中出现异常。
Exception raised during rendering: Unable to locate mode 0
java.lang.IllegalStateException: Unable to locate mode 0
at android.view.DisplayInfo.findMode(DisplayInfo.java:458)
at android.view.DisplayInfo.getMode(DisplayInfo.java:445)
at android.view.Display.getRefreshRate(Display.java:648)
at android.support.v7.widget.RecyclerView.onAttachedToWindow(RecyclerView.java:2392)
at android.view.View.dispatchAttachedToWindow(View.java:15392)
at android.view.ViewGroup.dispatchAttachedToWindow(ViewGroup.java:2953)
at android.view.ViewGroup.dispatchAttachedToWindow(ViewGroup.java:2960)
at android.view.ViewGroup.dispatchAttachedToWindow(ViewGroup.java:2960)
at android.view.ViewGroup.dispatchAttachedToWindow(ViewGroup.java:2960)
at android.view.ViewGroup.dispatchAttachedToWindow(ViewGroup.java:2960)
at android.view.ViewGroup.dispatchAttachedToWindow(ViewGroup.java:2960)
at android.view.ViewGroup.dispatchAttachedToWindow(ViewGroup.java:2960)
at android.view.AttachInfo_Accessor.setAttachInfo(AttachInfo_Accessor.java:42)
at com.android.layoutlib.bridge.impl.RenderSessionImpl.inflate(RenderSessionImpl.java:333)
at com.android.layoutlib.bridge.Bridge.createSession(Bridge.java:429)
at com.android.ide.common.rendering.LayoutLibrary.createSession(LayoutLibrary.java:389)
at com.android.tools.idea.rendering.RenderTask.compute(RenderTask.java:548)
at com.android.tools.idea.rendering.RenderTask.compute(RenderTask.java:533)
at com.intellij.openapi.application.impl.ApplicationImpl.runReadAction(ApplicationImpl.java:966)
at com.android.tools.idea.rendering.RenderTask.createRenderSession(RenderTask.java:533)
at com.android.tools.idea.rendering.RenderTask.lambda$inflate(RenderTask.java:659)
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)
这是 com.android.support:design:25.0.0
中 RecyclerView 的问题
可能那个版本有问题。
将版本更改为 24.1.1 解决了我的问题。
compile 'com.android.support:appcompat-v7:24.1.1'
compile 'com.android.support:support-v13:24.1.1'
compile 'com.android.support:design:24.1.1'
如果您没有删除提供的默认设置 gradle 导入也会更改此设置
androidTestCompile 'com.android.support:support-annotations:24.2.1'
临时解决方案是降级您的项目,
compile 'com.android.support:appcompat-v7:24.2.1'
compile 'com.android.support:design:24.2.1'
compile 'com.android.support:recyclerview-v7:24.2.1'
要么降级到 v24
或
以下既不是解决方案也不是解决方法。
如果您只想查看预览,请在布局 XML 中为 recyclerView 添加 app:layoutManager="0"。
添加它会抛出运行时 InflateException。因此,请在 运行 应用程序之前从 XML 布局文件中删除 属性。
只需将您的 compileSdkVersion 更改为 24 并降级依赖项:
compile 'com.android.support:appcompat-v7:24.2.1'
compile 'com.android.support:design:24.2.1'
compile 'com.android.support:recyclerview-v7:24.2.1'
compile 'com.android.support:cardview-v7:24.2.1'
就是这样。
更新后 android studio 在渲染过程中出现异常。
Exception raised during rendering: Unable to locate mode 0
java.lang.IllegalStateException: Unable to locate mode 0
at android.view.DisplayInfo.findMode(DisplayInfo.java:458)
at android.view.DisplayInfo.getMode(DisplayInfo.java:445)
at android.view.Display.getRefreshRate(Display.java:648)
at android.support.v7.widget.RecyclerView.onAttachedToWindow(RecyclerView.java:2392)
at android.view.View.dispatchAttachedToWindow(View.java:15392)
at android.view.ViewGroup.dispatchAttachedToWindow(ViewGroup.java:2953)
at android.view.ViewGroup.dispatchAttachedToWindow(ViewGroup.java:2960)
at android.view.ViewGroup.dispatchAttachedToWindow(ViewGroup.java:2960)
at android.view.ViewGroup.dispatchAttachedToWindow(ViewGroup.java:2960)
at android.view.ViewGroup.dispatchAttachedToWindow(ViewGroup.java:2960)
at android.view.ViewGroup.dispatchAttachedToWindow(ViewGroup.java:2960)
at android.view.ViewGroup.dispatchAttachedToWindow(ViewGroup.java:2960)
at android.view.AttachInfo_Accessor.setAttachInfo(AttachInfo_Accessor.java:42)
at com.android.layoutlib.bridge.impl.RenderSessionImpl.inflate(RenderSessionImpl.java:333)
at com.android.layoutlib.bridge.Bridge.createSession(Bridge.java:429)
at com.android.ide.common.rendering.LayoutLibrary.createSession(LayoutLibrary.java:389)
at com.android.tools.idea.rendering.RenderTask.compute(RenderTask.java:548)
at com.android.tools.idea.rendering.RenderTask.compute(RenderTask.java:533)
at com.intellij.openapi.application.impl.ApplicationImpl.runReadAction(ApplicationImpl.java:966)
at com.android.tools.idea.rendering.RenderTask.createRenderSession(RenderTask.java:533)
at com.android.tools.idea.rendering.RenderTask.lambda$inflate(RenderTask.java:659)
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)
这是 com.android.support:design:25.0.0
可能那个版本有问题。 将版本更改为 24.1.1 解决了我的问题。
compile 'com.android.support:appcompat-v7:24.1.1'
compile 'com.android.support:support-v13:24.1.1'
compile 'com.android.support:design:24.1.1'
如果您没有删除提供的默认设置 gradle 导入也会更改此设置
androidTestCompile 'com.android.support:support-annotations:24.2.1'
临时解决方案是降级您的项目,
compile 'com.android.support:appcompat-v7:24.2.1'
compile 'com.android.support:design:24.2.1'
compile 'com.android.support:recyclerview-v7:24.2.1'
要么降级到 v24
或
以下既不是解决方案也不是解决方法。
如果您只想查看预览,请在布局 XML 中为 recyclerView 添加 app:layoutManager="0"。
添加它会抛出运行时 InflateException。因此,请在 运行 应用程序之前从 XML 布局文件中删除 属性。
只需将您的 compileSdkVersion 更改为 24 并降级依赖项:
compile 'com.android.support:appcompat-v7:24.2.1'
compile 'com.android.support:design:24.2.1'
compile 'com.android.support:recyclerview-v7:24.2.1'
compile 'com.android.support:cardview-v7:24.2.1'
就是这样。