Using Snackbar you need to add android support design dependencies. Copy below dependencies and add to your build.gradle file.
Give an id to your layout. as I am using RelativeLayout so I give it an id like 'mylayout'
In MainActivity.java file inside onCreate() method added your layout id like
compile 'com.android.support:design:25.3.1'
Give an id to your layout. as I am using RelativeLayout so I give it an id like 'mylayout'
android:id="@+id/mylayout"
In MainActivity.java file inside onCreate() method added your layout id like