I am using the following RecyclerView:
<androidx.recyclerview.widget.RecyclerView ... />
which has the following dependency in the build.gradle:
implementation 'androidx.recyclerview:recyclerview:1.0.0'
which is downloaded after clicking the download button in front of the RecyclerView in Design mode of android studio.
I run my application on Oreo and it works perfectly.
But when i run the app on KitKat, the application is killed, so I comment out the RecyclerView and its related source code and run the application again and this time application runs properly on KitKat, so i realize that the problem is with the RecyclerView for the KitKat version.
Now i did a bit research and found that i have to use the:
implementation 'com.android.support:recyclerview-v7:28.0.0'
and following xml tag:
<android.support.v7.widget.RecyclerView ... />
Now my question is that what is the difference between the
<androidx.recyclerview.widget.RecyclerView ... />
implementation 'androidx.recyclerview:recyclerview:1.0.0'
and
<android.support.v7.widget.RecyclerView ... />
implementation 'com.android.support:recyclerview-v7:28.0.0'
Which one is created for which purpose and which one should be used in which situation? Why android studio download the one that is not supported on KitKat instead of downloading the one that is supported on almost previous version of android? Thanks!!!
The
RecyclerViewSupport Library andRecyclerViewAndroidX library are having the same purpose. The main difference is the package name. The AndroidX mainly a repackage and re-branded support library with the main purpose to ease the Android development process. All the support library capabilities is still existed in AndroidX, but the newest capabilities and development shifted to AndroidX now. But it doesn't mean the Support library is deprecated. See the following note from Support Library documentation :So, you should migrate to AndroidX for your recent project.
This probably a bug in your code or the least probability is a bug inside the AndroidX RecyclerView. We can't find the problem without your error log. So, you need to provide the error log in your question.
For new project, you should migrate to AndroidX. But for your legacy project that tightly depends on libraries that need a support library as dependency, you need to do one of the following:
android.enableJetifierin yourgradle.properties, see Migrating to AndroidX