Android Studio 2.2.2 更新后渲染预览错误 "Unable to locate mode 0"

Android Studio 2.2.2 error "Unable to locate mode 0" on rendering preview after update

我将 Android Studio 更新到版本 2.2.2,之后我将 compileSdkVersion 和 buildToolVersion 更改为 25.0.0 和 appcompat-V7:25.0.0,现在我无法构建项目并且 运行 项目完美,但我在渲染包含 RecyclerView 的活动时出错。这是错误详细信息:

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.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)

有人 运行 遇到同样的问题吗?有什么解决办法吗!?

同样的问题。通过将我的 build.gradle 设置为编译 appcompat-v7:24.0.3 而不是 25.0.0 来临时修复它。 希望这有帮助。

在 build.gradle(Module:App) 中将 RecyclerView 的版本从 25 更改为 24。

compile 'com.android.support:recyclerview-v7:24.0.0'

我不确定,但这可能有用。

现在我修复了它 - 在我更改的 styles.xml 文件中

"Theme.AppCompat.Light.DarkActionBar"

"Base.Theme.AppCompat.Light.DarkActionBar"

这是我很久以前遇到的一种 hack,用于解决以前 Android Studio 版本中的类似渲染问题。

重建你的项目

这是 Android 支持库版本 25.0.0 的错误,已在新的 25.0.1 中修复!

compile 'com.android.support:recyclerview-v7:25.0.1'