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

前端 未结 11 936
南方客
南方客 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:20
    implementation 'com.android.support:design:28.0.0'
    implementation 'com.android.support:support-annotations:28.0.0'
    

    set it in gradle.(module app) its working for me in android studio and device with orio.

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

    Try this

    dependencies {
     compile fileTree(include: ['*.jar'], dir: 'libs')
     testCompile 'junit:junit:4.12'
     compile 'com.android.support:appcompat-v7:22.2.0'
     compile 'me.zhanghai.android.materialprogressbar:library:1.1.4'
     compile 'com.android.support:design:22.2.1'
     }
    
    0 讨论(0)
  • 2021-02-02 06:23

    To get the the Snackbar into our Android proyect just add the reference of support:design library inside the build.gradle file :

    dependencies {
        ...
        ...
        compile 'com.android.support:design:25.0.1'
    }
    

    Be sure to sync your project with the gradle files , this will fix your problem.


    Your error message is:

    error: package android.support.design.R does not exist

    be sure to have the correct import:

    import android.support.design.widget.Snackbar;
    
    0 讨论(0)
  • 2021-02-02 06:23

    Just type fully qualified class name android.support.design.widget.SnackBar instead of just SnackBar at every occurrence . It solves the issue for me.

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

    I solved the problem now :)

    1. Open [File] -> [Project Structure...]

    2. Select [app] in the left pad

    3. Select [Dependencies] in the right tabs

    4. Click [+] button on the right side

    5. Select [1 Library dependency]

    6. Choose [com.android.support:design ~~]

    7. Click [OK] button and so on

    Result: library added in [Project's External Libraries]

    ------ edit -----------------------------------

    You can also add this External library in build.gradle(Module:app)

    press Alt+Enter in build.gradle(Module:app)

    -> add library dependency

    -> choose what you need

    and press "Sync Now" positioned up right corner

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