【问题标题】:Cannot resolve dependencies 'com.github.smarteist:autoimageslider:1.4.0-appcompat'无法解析依赖\'com.github.smarteist:autoimageslider:1.4.0-appcompat\'
【发布时间】:2022-09-22 22:38:18
【问题描述】:

在我的项目中,我正在尝试构建自动图像滑块视图 我正在使用 SliderView 库。我添加了来自 github 的依赖项:

implementation \'com.github.smarteist:autoimageslider:1.4.0-appcompat\'

但是当在项目中添加这个依赖并同步项目时,并尝试在我的 xml 文件中使用这个库。尽管项目已成功构建,但此库未出现。

构建.gradle(应用程序):

plugins {
   id \'com.android.application\'
}

android {
    compileSdk 32

    defaultConfig {
        applicationId \"com.nctr.cd.bmvp\"
        minSdk 26
        targetSdk 32
        versionCode 1
        versionName \"1.0\"

        testInstrumentationRunner \"androidx.test.runner.AndroidJUnitRunner\"
    }

    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile(\'proguard-android-optimize.txt\'), \'proguard-rules.pro\'
        }
    }
    compileOptions {
        sourceCompatibility JavaVersion.VERSION_1_8
        targetCompatibility JavaVersion.VERSION_1_8
    }
}

dependencies {

    implementation \'androidx.appcompat:appcompat:1.4.1\'
    implementation \'com.google.android.material:material:1.6.1\'
    implementation \'androidx.constraintlayout:constraintlayout:2.1.4\'
    implementation \'com.gitee.archermind-ti:autoimageslider:1.0.0-beta\'
    testImplementation \'junit:junit:4.13.2\'
    implementation \'androidx.legacy:legacy-support-v4:1.0.0\'
    androidTestImplementation \'androidx.test.ext:junit:1.1.3\'
    androidTestImplementation \'androidx.test.espresso:espresso-core:3.4.0\'

    // room database dependency
    def room_version = \"2.4.3\"
    implementation \"androidx.room:room-runtime:$room_version\"
    annotationProcessor \"androidx.room:room-compiler:$room_version\"

    //retrofit http client dependency
    implementation \'com.squareup.retrofit2:retrofit:2.4.0\'
    implementation \'com.squareup.retrofit2:converter-gson:2.4.0\'

    //swipe refresh dependency to add pull to refresh for recycleView
    implementation \"androidx.swiperefreshlayout:swiperefreshlayout:1.1.0\"

    // dependency for gson
    implementation \'com.google.code.gson:gson:2.9.1\'

       // dependency for loading image from url

    implementation \'com.github.bumptech.glide:glide:4.11.0\'

    // google service dependency
    implementation \'com.google.android.gms:play-services-maps:16.1.0\'
    implementation \'com.google.android.gms:play-services-location:16.0.0\'
    // auto image slider dependency
    implementation \'com.github.smarteist:autoimageslider:1.4.0-appcompat\'
}
  • 您能否发布您的build.gradle 文件,以便我们检查那里发生了什么?另外,您是否使用多模块项目?您是否在正确的build.gradle 中添加了此依赖项?

标签: android gradle


【解决方案1】:

请检查您的 build.gradle 中是否缺少 jcenter()

allprojects {
    repositories {
        google()
        //here
        jcenter()
        mavenCentral()
   
    }
}

并确保您的项目在 appcompat 依赖项上。

【讨论】:

  • 是的,我在 setting.gradle 中添加了 jcenter(),这很好。谢谢。很多
  • 这是否意味着您已经解决了它或错误仍然存​​在?
  • 所以将我的答案标记为勾号(接受),而不是为了声誉,为了对答案的信任。
猜你喜欢
  • 2016-10-24
  • 2016-09-13
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2017-05-06
  • 2019-01-24
  • 2021-08-04
相关资源
最近更新 更多