Yuanq
Yuanq

Reputation: 25

Android Studio:An alert box showed when I try to add RecyclerView

enter image description here

enter image description here

Warning text is:

This operation requires the library androidx.recyclerview:recyclerview:+.

Problem: Inconsistencies in the existing project dependencies found. Version incompatibility between: - androidx.appcompat:appcompat:1.1.0@aar and: - androidx.appcompat:appcompat:1.1.0@aar

With the dependency: - androidx.annotation::1.1.0 versus: - androidx.annotation::2.0.0

The project may not compile after adding this library. Would you like to add it anyway

After I chose OK and added the RecyclerView,I still can't use it because when I selected the added RecyclerView it shows No component selected in the Attributes.

Upvotes: 2

Views: 333

Answers (1)

Rahul Gaur
Rahul Gaur

Reputation: 1699

Add this in your app.gradle

implementation 'androidx.recyclerview:recyclerview:1.1.0'
implementation 'com.android.support:recyclerview-v7:29.0.0'

or you can add the Google Material Design Lib using

implementation 'com.google.android.material:material:1.0.0'

So you can use all Material Components like CardView, SnackBar, etc

Hope this will help!

Upvotes: 2

Related Questions