So my code simply makes a list of CardViews using RecyclerView. Upon running my code i kept getting a weird error claiming there was an error in my xml. After tinkering for
You should add the RecyclerView in the XML in this way:
<android.support.v7.widget.RecyclerView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:id="@+id/cardList">
</android.support.v7.widget.RecyclerView>
Hope it helps!
I meet this problem today. And solved it.
first step:keep the support-libs you used are same version
compile 'com.android.support:appcompat-v7:23.1.1'
compile 'com.android.support:support-v4:23.1.1'
compile 'com.android.support:recyclerview-v7:23.1.1'
second step:you should add recyclerView to your proguard files
-keep class android.support.v7.widget.** {*;}
// I`ve just keep all widgets
Make sure to include before you add RecyclerView to your XML
compile 'com.android.support:recyclerview-v7:22.2.0'
compile 'com.android.support:appcompat-v7:22.2.0'
If you created RecyclerView in your XML before adding these dependencies, to make it work you should remove (comment) your recycler view, build project without it and then add it back. Otherwise it still shows Inflate exception in binary XML line #n.
RecyclerView
is not included in base Android framework, only widgets in base Android framework (like ListView
, GridView
etc) can be specified in layout without full namespace. RecyclerView
is part of recyclerview-v7 support library.
android.support.v7.widget.RecyclerView
not like RecyclerView
now ready to lunch. Good trails