Can't find android.support.design.widget.Snackbar in support design library

前端 未结 11 935
南方客
南方客 2021-02-02 05:31

I develop own library module where I use Snackbar.

Here is my Gradle file:

apply plugin: \'com.android.library\'

android {
    compileSdkV         


        
相关标签:
11条回答
  • 2021-02-02 06:12

    Use implementation "com.android.support:design:23.0.0"

    or Change the Sdk to 28 and use implementation "com.android.support:design:28.0.0"

    0 讨论(0)
  • 2021-02-02 06:15

    You must add the design dependency in your gradle file (module app) according to


    AndroidX build artifact

    implementation "com.google.android.material:material:1.1.0-alpha06"
    


    Old build artifact

    implementation "com.android.support:design:28.0.0"
    


    If you are using Support libraries, you can visit Support Library Packages  |  Android Developers, for the latest Design Support Library version. If you're new to AndroidX and want to use it, you can find more information about migrating to the new dependencies here.

    Source: http://android-developers.blogspot.co.il/2015/05/android-design-support-library.html
    (Scroll all the way down)

    0 讨论(0)
  • 2021-02-02 06:16

    Remove Support v4 from your project and then add support design library.

    0 讨论(0)
  • 2021-02-02 06:17

    Dependencies may change with upgrading of android sdk versions, i am creating application in sdkversion 27. I have added the following dependency for snackbar.
    implementation 'com.android.support:design:27.1.1'

    0 讨论(0)
  • 2021-02-02 06:18

    If you are migrating to androidx then use

    com.google.android.material.R.id.snackbar_text

    instead of

    android.support.design.R.id.snackbar_text

    Don't miss to import import com.google.android.material.snackbar.Snackbar;

    Also implement implementation "com.google.android.material:material:1.2.0-alpha02"

    0 讨论(0)
  • 2021-02-02 06:18

    After upgrading to androidx it will show error.You have to import this library

    import com.google.android.material.snackbar.Snackbar;
    
     Snackbar snackbar = Snackbar.make(view, R.string.Mapview, Snackbar.LENGTH_INDEFINITE);
                View snackbarView = snackbar.getView();
                TextView textView = (TextView) snackbarView.findViewById(com.google.android.material.R.id.snackbar_text);
                textView.setMaxLines(5);
                snackbar.show();
    

    Hope it will solve your problem.

    0 讨论(0)
提交回复
热议问题