0

I have recently updated my Android Studio version to 2.3

I am working on a project now and I've noticed that I am unable to import Snackbar class. I never had that problem before.

I can use it by adding compile 'com.nispok:snackbar:2.6.1' and I can import it then, but I don't think I should have to do that instead of just using Android's android.support.design.widget.Snackbar;

This is are my dependencies from build.gradle:

dependencies {
    compile fileTree(dir: 'libs', include: ['*.jar'])
    androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
        exclude group: 'com.android.support', module: 'support-annotations'
    })
    compile 'com.android.support:appcompat-v7:25.2.0'
    compile 'com.google.firebase:firebase-database:10.0.1'
    compile 'com.android.support.constraint:constraint-layout:1.0.2'
    testCompile 'junit:junit:4.12'
}

I have also tried to play around with DataBinding concept in my project but I don't think this could cause that issue?

Thank you.

Jacas
  • 331
  • 6
  • 11
  • SnackBar is available in `com.android.support:design` library – Alim Parkar Mar 14 '17 at 12:01
  • could you please tell me what version of `com.android.support:design` do I need to import to make sure I am using the newest one? – Jacas Mar 14 '17 at 12:02
  • the latest one is `'com.android.support:design:25.2.0'` – Alim Parkar Mar 14 '17 at 12:04
  • @Alim Parkar thank you very much. sorry if my question was very trivial but I spent last hour trying to figure out what's wrong.. should not Android Studio add that automatically to a new project btw? it doesn''t seem to do it with any of my new projects – Jacas Mar 14 '17 at 12:07
  • Studio does not add the library automatically as it does not know which library the class could belong to. – Alim Parkar Mar 14 '17 at 12:10

1 Answers1

1

You are missing the compile 'com.android.support:design:25.2.0' in your dependencies. As the library is not added you are unable to get the Snackbar class.

Alim Parkar
  • 632
  • 3
  • 9