Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Rendering issue in XML preview : Unable to locate mode 0 [duplicate]

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)
like image 640
Aman Jain Avatar asked Oct 23 '16 13:10

Aman Jain


4 Answers

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'
like image 148
tikhonos Avatar answered Nov 16 '22 08:11

tikhonos


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.

like image 21
Aditya Teja Avatar answered Nov 16 '22 08:11

Aditya Teja


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.

like image 3
Ícaro Magalhães Avatar answered Nov 16 '22 06:11

Ícaro Magalhães


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'
like image 2
Sanket Berde Avatar answered Nov 16 '22 08:11

Sanket Berde