96

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?

ElegyD
  • 4,393
  • 3
  • 21
  • 37
dudi
  • 5,523
  • 4
  • 28
  • 57
  • I have listed some of the correction to `Migrate-to-Android-X` problems [here](https://stackoverflow.com/a/54579196/2408879) – makata Jan 16 '20 at 08:03

5 Answers5

269

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

dudi
  • 5,523
  • 4
  • 28
  • 57
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.

Ali Nem
  • 5,252
  • 1
  • 42
  • 41
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.

sRawat
  • 187
  • 2
  • 4
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)

user8730407
  • 147
  • 1
  • 3
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

Ali Nawaz
  • 2,016
  • 20
  • 30