You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

新建Android Gradle项目无法导入Maven依赖求助

解决依赖同步异常:Failed to resolve: com.github.smarteist:autoimageslider:1.4.0

问题描述

同步Android项目时出现以下异常:

Failed to resolve: com.github.smarteist:autoimageslider:1.4.0
Show Details
Affected Modules: app

用户当前配置文件如下:

项目级build.gradle

plugins {
    id 'com.android.application' version '7.4.1' apply false
    id 'com.android.library' version '7.4.1' apply false
}

settings.gradle

pluginManagement {
    repositories {
        google()
        mavenCentral()
        gradlePluginPortal()
    }
}
dependencyResolutionManagement {
    repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS)
    repositories {
        google()
        mavenCentral()
        maven { url "https://jitpack.io" }
    }
}
rootProject.name = "PixelCraft"
include ':app'

应用级build.gradle

plugins {
    id 'com.android.application'
}

android {
    namespace 'com.gliesestudio.pixelcraft'
    compileSdk 33

    defaultConfig {
        applicationId "com.gliesestudio.pixelcraft"
        minSdk 24
        targetSdk 33
        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.6.1'
    implementation 'com.google.android.material:material:1.9.0'
    implementation 'androidx.constraintlayout:constraintlayout:2.1.4'
    implementation 'androidx.viewpager2:viewpager2:1.0.0'
    implementation 'com.github.smarteist:autoimageslider:1.4.0' //Not getting imported

    testImplementation 'junit:junit:4.13.2'
    androidTestImplementation 'androidx.test.ext:junit:1.1.5'
    androidTestImplementation 'androidx.test.espresso:espresso-core:3.5.1'
}

解决方案

1. 替换为最新稳定版本

1.4.0版本可能存在JitPack构建失效或已被弃用的情况,建议替换为仓库最新的稳定版本。修改应用级build.gradle中的依赖:

implementation 'com.github.smarteist:autoimageslider:2.3.0'

2. 确认仓库配置有效性

你的settings.gradle中已正确添加JitPack仓库,无需修改。若后续仍有问题,可确认仓库地址格式是否正确:

maven { url "https://jitpack.io" }

3. 清理Gradle缓存并重新同步

执行以下操作:

  • 点击Android Studio顶部菜单栏的 File -> Invalidate Caches...
  • 勾选 Invalidate and Restart,等待IDE重启后重新同步项目

4. 检查网络连接

确保网络可正常访问JitPack仓库,若存在代理或网络限制,需配置相应的代理规则。


内容的提问来源于stack exchange,提问作者Mazidul Islam

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.07.18 12:30:27