What do I need to change in gradle.build in order to implement Snackbar


I am trying to implement Snackbar messages. (This is for an app which I have for personal use which has always worked satisfactorily with Toast messages on old phones, but I now need to implement Snackbar because Toast cannot show multiline messages on a new phone.)

Following online advice I have included the following lines in my build.gradle (Module :app) file.

implementation 'com.google.android.material:material:1.0.0'
implementation 'com.google.android.material:snackbar:1.0.0'

With these lines included, and after a "Sync", Android Studio is not reporting any errors in the Java code. However, when I try to install the app Gradle fails with the following error:

org.gradle.api.internal.artifacts.ivyservice.DefaultLenientConfiguration$ArtifactResolveException: Could not resolve all files for configuration ':app:debugRuntimeClasspath'

It looks as if Gradle does not know where to find the new dependencies. How can I resolve this, please?

1
Jun 17 at 6:26 PM
User Avatarprepbgg
#android#gradle#snackbar

Accepted Answer

Step #1: Remove implementation 'com.google.android.material:snackbar:1.0.0'. That does not appear to have ever existed. Snackbar should be in com.google.android.material:material, AFAIK.

Step #2: Strongly consider something newer than 1.0.0, which is from 2018. The most recent stable version is 1.14.0.

Note that the Material Components for Android are in maintenance mode, as Google moves to Jetpack Compose as being the primary UI toolkit.

User AvatarCommonsWare
Jun 17 at 6:40 PM
5