Can't resolve android.support.design. after migration to AndroidX
Asked Answered
M

5

97

I am trying to get the TextView of the Snackbar with this code snippet:

snackbarView.findViewById<TextView>(android.support.design.R.id.snackbar_text)  

but Android Studio does not resolve the design library.

How can I get this code to work?

Manhandle answered 18/10, 2018 at 11:35 Comment(1)
I have listed some of the correction to Migrate-to-Android-X problems hereRitualize
M
274

Solved with this solution: snackbarView.findViewById<TextView>(com.google.android.material.R.id.snackbar_text)

Manhandle answered 18/10, 2018 at 11:45 Comment(3)
was struggling with this just now :)Gastrulation
@varun Thank you very much. Glad to help and give something back to the community!Manhandle
@apurvthakkar NP. Glad I could help. Happy codingManhandle
E
54

Thanks for the great answer by @dudi, in general in migration to androidX you can replace

android.support.design.R

with

com.google.android.material.R

I have written a brief step-by-step article on AndroidX migration here, if someone is interested to know more.

Evannia answered 1/5, 2019 at 2:8 Comment(0)
O
15

Changing this :

android.support.design.R

with

com.google.android.material.R

solves the problem . After Migration to AndroidX we are working with different library.

Oringas answered 30/12, 2019 at 7:26 Comment(1)
Just a repetition of the accepted answer.Hyaloplasm
G
13

You've migrated to AndroidX, which means the library is different now.

(android.support.design.R.id.snackbar_text) to (com.google.android.material.R.id.snackbar_text)

Grith answered 25/7, 2019 at 6:58 Comment(1)
Sorry, but this is just a repetition of what the accepted answer states.Magician
V
4

As android.support.design.R is no more supported after androidx migration, So you need to replace it

with

com.google.android.material.R

Vermicide answered 16/9, 2020 at 10:7 Comment(1)
Just a repetition of the accepted answer.Hyaloplasm

© 2022 - 2024 — McMap. All rights reserved.