38

After updating the android studio exception occured during rendering.

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$2.compute(RenderTask.java:548)
at com.android.tools.idea.rendering.RenderTask$2.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$53(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)
Aman Jain
  • 2,975
  • 1
  • 20
  • 35
  • 1
    Known issue, http://stackoverflow.com/questions/40161934/exception-raised-during-rendering-unable-to-locate-mode-0 – Stefan Oct 23 '16 at 13:03
  • 1
    Issue has been resolved. Update Support Library to the new version. `compile 'com.android.support:appcompat-v7:25.0.1'` `compile 'com.android.support:design:25.0.1'` `compile 'com.android.support:recyclerview-v7:25.0.1'` – Aman Jain Nov 22 '16 at 07:36
  • compile 'com.android.support:recyclerview-v7:25.0.1' compile 'com.android.support:appcompat-v7:25.0.1' compile 'com.android.support:design:25.0.1' it will work.. – KAMAL VERMA Feb 28 '17 at 06:20

4 Answers4

35

That's problem with RecyclerView in com.android.support:design:25.0.0

Maybe there is some issue in that version. Changed version to 24.1.1 solved my problem.

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'

in case you not have not removed the default provided gradle imports change this also

androidTestCompile 'com.android.support:support-annotations:24.2.1'
Aniruddha K.M
  • 7,361
  • 3
  • 43
  • 52
tikhonos
  • 592
  • 4
  • 11
5

Either downgrade to v24

OR

The following is neither a solution nor a work around.

If you ONLY want to see the PREVIEW, add app:layoutManager="0" for the recyclerView in a layout XML.

Adding this will throw runtime InflateException. So, please remove that property from XML layout file before running the app.

3

Just change your compileSdkVersion to 24 and downgrade the dependencies:

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'

That's it.

2

A Temporary solution is to downgrade your project,

 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'
Sanket Berde
  • 6,555
  • 4
  • 35
  • 39