Exception raised during rendering, using RecyvlerView

1.2k views Asked by At

I am trying to use RecyclerView in my app. Code:

The Activity:

public class TecnicoActivity extends Activity {

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.tecnicolayout);
}
}

The Layout:

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent" android:layout_height="match_parent">

<android.support.v7.widget.RecyclerView
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:layout_alignParentTop="true"
    android:layout_alignParentStart="true" />
</RelativeLayout>

This way, I am receiving an error message in layout window:

Exception raised during rendering:
android.support.v4.view.ViewCompat.getDisplay(Landroid/view/View;)Landroid/view/Display;(Details)

Clicking in details shows this exception:

java.lang.NoSuchMethodError: android.support.v4.view.ViewCompat.getDisplay(Landroid/view/View;)Landroid/view/Display;
at android.support.v7.widget.RecyclerView.onAttachedToWindow(RecyclerView.java:2447)
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.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$70(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)

My gradle file:

dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
    exclude group: 'com.android.support', module: 'support-annotations'
})
compile 'com.android.support:appcompat-v7:22.2.1'
testCompile 'junit:junit:4.12'
compile 'com.android.support:design:22.2.0'
compile 'com.android.support:recyclerview-v7:+'
}

How can I get rid of this error?

1

There are 1 answers

0
Morse On

Repeated question [Exception raised during rendering: Unable to locate mode 0

Exception raised during rendering: Unable to locate mode 0

app level gradle compile with latest google libraries

Do this

compile 'com.android.support:recyclerview-v7:2x.x.x' compile 'com.android.support:appcompat-v7:2x.x.x' compile 'com.android.support:design:2x.x.x'

where 2x.x.x is current version of latest google apk library

At the time of this post it is

25.3.1