在Android Studio中添加库?

时间:2019-02-28 05:14:52

标签: android github android-glide

当我想添加该库时:

implementation 'com.github.bumptech.glide:glide:4.9.0'

我的android出现此错误:

Unable to resolve dependency for ':app@debug/compileClasspath': Could not resolve com.github.bumptech.glide:glide:4.9.0.

这是我的应用模块

apply plugin: 'com.android.application'
android {
compileSdkVersion 27
defaultConfig {
    applicationId "com.example.mahdi.chatapp"
    minSdkVersion 16
    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 {
    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'
    implementation 'com.google.firebase:firebase-auth:16.1.0'
    implementation 'com.google.firebase:firebase-config:16.3.0'
    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 'com.android.support:support-v4:27.1.1'
    implementation 'com.android.support:design:27.1.1'
    implementation 'com.google.firebase:firebase-core:16.0.7'
    implementation 'com.google.firebase:firebase-database:16.0.6'
    implementation 'com.android.support:cardview-v7:27.1.1'
    implementation 'com.rengwuxian.materialedittext:library:2.1.4'
    implementation 'de.hdodenhof:circleimageview:3.0.0'
    implementation 'com.github.bumptech.glide:glide:4.9.0'
}

apply plugin: 'com.google.gms.google-services'

3 个答案:

答案 0 :(得分:1)

您是否已将此代码添加到Gradle文件中

repositories {
  mavenCentral()
  google()
}

答案 1 :(得分:1)

使用滑行的最新版本,即高于版本4, 您必须添加一个额外的依赖项(glide编译器)

dependencies {
 implementation 'com.github.bumptech.glide:glide:4.9.0'
 annotationProcessor 'com.github.bumptech.glide:compiler:4.9.0'
}

在存储库中,您必须添加

repositories {
  mavenCentral()
  google()
}

参考:https://github.com/bumptech/glide

答案 2 :(得分:1)

您尚未添加注释处理器

repositories {
mavenCentral()
maven { url 'https://maven.google.com' }
}

dependencies {
compile 'com.github.bumptech.glide:glide:4.9.0'
annotationProcessor 'com.github.bumptech.glide:compiler:4.9.0'
}

这是Glide文档中提供的下载glide的代码。查看此链接:http://bumptech.github.io/glide/doc/download-setup.html#gradle

希望这会有所帮助!