简体   繁体   中英

How to add library in android project?

when I want to add this library:

implementation 'com.daimajia.slider:library:1.1.5@aar'

My android studio crashed this is my app module :

    android {
    compileSdkVersion 27
    defaultConfig {
        applicationId "com.example.mahdi.introductionapps"
        minSdkVersion 15
        targetSdkVersion 27
        versionCode 1
        versionName "1.0"
        testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
}

Dependencies:

    dependencies {
    implementation fileTree(include: ['*.jar'], dir: 'libs')
    implementation 'com.android.support:appcompat-v7:27.1.1'
    implementation 'com.android.support.constraint:constraint-layout:1.1.3'
    testImplementation 'junit:junit:4.12'
    androidTestImplementation 'com.android.support.test:runner:1.0.2'
    androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'
    implementation 'de.hdodenhof:circleimageview:3.0.0'
    implementation 'com.android.support:design:27.1.1'
    implementation 'com.android.support:cardview-v7:27.1.1'
    implementation 'com.nineoldandroids:library:2.4.0'
    implementation 'com.daimajia.slider:library:1.1.5@aar'
}

and this is my error :

Unable to resolve dependency for ':app@debug/compileClasspath': Could not resolve com.daimajia.slider:library:1.1.5.

Try doing these things

Clean & Rebuild Project

Or

File > Invalidate Caches and Restart > Invalidate and Restart

Or

Uncheck Gradle Work Offline

  1. Try File->Invalidate Caches and Restart->Invalidate and Restart
  2. If no luck try, File->Other Settings->Default Settings->Build, Execution, Deployment->Build Tools->Gradle->Offline work and uncheck it.

There is no problem with the library.

  1. Go to Build > Clean Project.
  2. then Build >Rebuild Project. and the library will be added normally. Happy coding

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM