2017-08-11 119 views
0

Recyclerview渲染錯誤,此錯誤阻止預覽整個佈局,因此我無法看到我應用的更改。我尋找解決方案,但沒有任何相關的這個錯誤幫助。Android Recyclerview渲染錯誤

java.lang.NoSuchMethodError: android.support.v4.view.ViewCompat.getDisplay(Landroid/view/View;)Landroid/view/Display; at android.support.v7.widget.RecyclerView.onAttachedToWindow(RecyclerView.java:2502) at android.view.View.dispatchAttachedToWindow(View.java:15395) 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:368) at com.android.tools.idea.rendering.RenderTask$2.compute(RenderTask.java:567) at com.android.tools.idea.rendering.RenderTask$2.compute(RenderTask.java:549) at com.intellij.openapi.application.impl.ApplicationImpl.runReadAction(ApplicationImpl.java:863) at com.android.tools.idea.rendering.RenderTask.createRenderSession(RenderTask.java:549) at com.android.tools.idea.rendering.RenderTask.lambda$inflate$1(RenderTask.java:680) 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)

+0

哪個版本使用(Recyclerview)? –

+0

編譯 'com.android.support:recyclerview-v7:25.3.1' – DiRiNoiD

+0

compileSdkVersion 25 buildToolsVersion '25 .0.2' – DiRiNoiD

回答

0

java.lang.NoSuchMethodError: android.support.v4.view.ViewCompat.getDisplay(Landroid/view/View;)Landroid/view/Display; at android.support.v7.widget.RecyclerView.onAttachedToWindow(RecyclerView.java:2502) at android.view.View.dispatchAttachedToWindow(View.java:15395)

CHANGE

android { 
    compileSdkVersion 26 
    buildToolsVersion '26.0.1' 

    defaultConfig { 
    targetSdkVersion 26 
    } 

compile 'com.android.support:recyclerview-26.0.1' 

從預覽節Clean-Rebuild-Restart &選擇API等級26後。

+0

我已經做了設置,但它仍然給出了警告 – DiRiNoiD

+0

@IlyasDirin https://issuetracker.google.com/issues/36997736 –

+0

@IlyasDirin'以下類無法實例化recyclerview'另一個問題。我希望你克服' NoSuchMethodError'問題 –

1

gradlesync中添加以下行。

compile 'com.android.support:appcompat-v7:23.4.0' 
compile 'com.android.support:design:23.4.0' 
compile 'com.android.support:recyclerview-v7:23.4.0' 
0

我有這個相同的錯誤。 嘗試在您的RecyclerView中刪除您的android:animateLayoutChanges

祝你好運