0

I was making an application (API 26) which uses RecyclerView. I use the following line in my build l.gradle

dependencies {
    implementation 'com.android.support:recyclerview-v7:28.0.0'
}

But however this doesn't work of API 26. Is there any way that I can use Recyclerview for API 26. Thank you!

Karan Gandhi
  • 303
  • 1
  • 2
  • 15
  • 2
    I recommend you to use androidX library instead of support library – AgentP Jul 03 '20 at 06:25
  • https://developer.android.com/topic/libraries/support-library/packages - check this link. Share your code for more information. – learner Jul 03 '20 at 06:26
  • [AgentP](https://stackoverflow.com/users/9365212/agentp) can you elaborate on the topic – Karan Gandhi Jul 03 '20 at 06:32
  • use this `com.google.android.material:material:1.0.0` – Wini Jul 03 '20 at 06:34
  • "this doesn't work" isn't descriptive enough to help people understand your problem. Instead, describe what the exact observed behavior is and what the expected/intended behavior should be. For UI issues, a screenshot or video is usually helpful. Include any example inputs, expected/actual outputs, and the exact text of any error messages, including the full [stack trace](/a/23353174) of any exceptions, if applicable, as well as which line of code the stack trace points to. Please see [ask] and [How to create a Minimal, Reproducible Example](/help/minimal-reproducible-example). – Ryan M Jul 03 '20 at 07:35
  • @Wini that has nothing to do with RecyclerView, could you explain how that would help? – Ryan M Jul 03 '20 at 07:38
  • 1
    @KaranGandhi to elaborate a bit on AndroidX: The `android.support` classes are all deprecated, no longer receiving bug fixes or new features, and should not be used in new code. You should [migrate to AndroidX](https://developer.android.com/jetpack/androidx/migrate). – Ryan M Jul 03 '20 at 07:38
  • 2
    My guess is that your compile SDK is set too low, and you need to increase it to at least 28, which won't affect anything other than allowing you to compile against libraries that use newer APIs. Let me know if that fixes your problem, and I can post it as an answer if it does. – Ryan M Jul 03 '20 at 07:44
  • even i agree with @RyanM ...actually karan you should use the latest version of android studio which is 4.0...the latest version uses the androidx libraries...the dependency i gave you `com.google.android.material:material:1.0.0` is use for recycleview,cardview,etc purposes...use the latest one i suggest – Wini Jul 03 '20 at 07:51
  • Ok thank you all for you suggestions – Karan Gandhi Jul 03 '20 at 08:44
  • @KaranGandhi could you confirm what the actual problem was? Did switching to AndroidX solve it, or did my suggestion solve it? – Ryan M Jul 03 '20 at 15:23
  • Yes my problem was solved by switching to androidx – Karan Gandhi Jul 03 '20 at 16:34
  • Glad to hear it! If you could edit your question to describe the exact problem you had to help people who find this question in the future, that would be very helpful. – Ryan M Jul 03 '20 at 22:37

1 Answers1

0

Why don't you use androidX? To know more details about it you can visit https://developer.android.com/jetpack/androidx

dependencies {
    implementation 'androidx.recyclerview:recyclerview:1.1.0'
}
towhid
  • 2,778
  • 5
  • 18
  • 28
  • Will I have to change any code which I have written? – Karan Gandhi Jul 03 '20 at 07:15
  • While I agree with this advice, I'm not sure how it could solve the problem. – Ryan M Jul 03 '20 at 07:35
  • androidx supports almost all the previous version of the android. You can learn more from here, https://developer.android.com/jetpack/androidx You can use android studios migrate to androidX function. it will do all the required changes and also backup your code too. In case the operation fails or doesn't work for you, than you can revert. – towhid Jul 03 '20 at 10:20