27

When migrating a project or switching between branches which are and aren't migrated, Android Studio cannot build projects because it cannot find the android.support.design.widget.Snackbar package. Support/Design packages are removed but the migration table does not list the correct new package for this component.

Nick Cardoso
  • 20,807
  • 14
  • 73
  • 124

5 Answers5

26

This took a long time to resolve, as until your project successfully builds, autocomplete will not function to lookup packages.

The correct package to use is:

com.google.android.material.snackbar.Snackbar

It is also important to remember to change this on the XML tags as well as the imports if the migration has not worked successfully.

Nick Cardoso
  • 20,807
  • 14
  • 73
  • 124
8

Old build artifact com.android.support:design now solves in com.google.android.material:material:1.0.0 for AndroidX build artifact.

Minding
  • 1,383
  • 1
  • 17
  • 29
Nicola Gallazzi
  • 7,897
  • 6
  • 45
  • 64
  • 1
    For anyone searching: Currently the lastest stable is "com.google.android.material:material:1.0.0". – Minding Aug 10 '19 at 14:26
7

Add implementation "com.google.android.material:material:1.1.0" to your app-level build.gradle.

Also, ensure that your project is set up to migrate old packages to Androidx by including this in your gradle.properties file:

android.useAndroidX=true android.enableJetifier=true

Dennis Murage
  • 401
  • 8
  • 12
2

Import

com.google.android.material.snackbar.Snackbar;

instead of

android.support.design.widget.Snackbar;

if you shifted to androidx and AS couldn't find the package anymore.

Derryl Thomas
  • 1,324
  • 12
  • 22
-1

Updating to Anko version 0.10.8 will resolve this, it will tell you that snackbar(view, int) is now deprecated, instead of it you will use view.snackbar(int: Message)

Odaym
  • 1,896
  • 1
  • 20
  • 31