2016-12-19 3 views
0

J'essaie d'utiliser RecyclerView dans mon application. Code:Exception levée lors du rendu, en utilisant RecyvlerView

L'activité:

public class TecnicoActivity extends Activity { 

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

La mise en page:

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

De cette façon, je reçois un message d'erreur dans la fenêtre de mise en page:

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

Cliquer dans les détails montre cette 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) 

Mon fichier gradle:

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:+' 
} 

Comment puis-je me débarrasser de cette erreur?

+0

double possible de [exception soulevée lors du rendu: Impossible de trouver le mode 0] (http: // stackoverflow .com/questions/40161934/exception-levée-pendant-rendu-impossible-de-localiser-mode-0) – Soren

Répondre

1

question répétée [Exception soulevée lors du rendu: Impossible de trouver le mode 0

Exception raised during rendering: Unable to locate mode 0

compilation

niveau app gradle avec les dernières bibliothèques google

Pour ce faire,

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'

où 2x.xx est la version actuelle du dernier g oogle bibliothèque apk

Au moment de ce poste, il est

25.3.1