HelloCW
HelloCW

Reputation: 2325

Why can't I find com.android.support:design:22.2.0 in Choose Library Dependency in Android Studio?

I hope to use Snackbar in Android Studio, I have read http://android-developers.blogspot.sg/2015/05/android-design-support-library.html.

So I add compile 'com.android.support:design:22.2.0' in build.gradle. Snackbar.make(...) works well.

I open Projec Structure in Android Studio, I think I can find the com.android.support:design:22.2.0 item in Choose Library Dependency UI, but in fact the item isn't be listed, why?

BTW, I have updated my Android.

Choose Library Dependency Screenshot

enter image description here

Updated Screenshot

enter image description here

build.gradle

apply plugin: 'com.android.application'

android {
    compileSdkVersion 22
    buildToolsVersion "22.0.1"

    defaultConfig {
        applicationId "info.dodata.messagecleanup"
        minSdkVersion 9
        targetSdkVersion 22
        versionCode 9
        versionName "1.09"
        archivesBaseName = "MessageCleanup-V" + versionName
    }


    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'           
        }

        debug {            
        }
    }
}


dependencies {
    compile fileTree(dir: 'libs', include: ['*.jar'])
    compile 'com.android.support:appcompat-v7:22.1.1'
    compile 'com.google.android.gms:play-services:7.3.0'
    compile 'com.android.support:design:22.2.0'
}

My Code

Snackbar.make(mView, "Hello SnackBar!", Snackbar.LENGTH_SHORT)
                        .setAction("Undo", new View.OnClickListener() {
                            @Override
                            public void onClick(View v) {
                                // Perform anything for the action selected
                                Toast.makeText(mContext, "I click Undo",Toast.LENGTH_LONG).show();
                            }
                        })
                        .show();

Upvotes: 2

Views: 3632

Answers (1)

minh the
minh the

Reputation: 19

  1. Open SDK Manager, then update Android Support Library, Android Support Repository to latest
  2. Config AndroidManifest.xml with compileSdkVersion > = 22 , buildToolsVersion >= 22 (because design library only supports API >= 22)
  3. Open sdk\extras\android\m2repository\com\android\support to know exactly the revision we have now

    compile 'com.android.support:appcompat-v7:22.2.0'
    compile 'com.android.support:design:22.2.0'
    

    Note that we need to add two libraries with the same revision (22.2.0 or ...)

  4. build successful

Upvotes: 2

Related Questions