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

更换系统后Android项目无法解析GitHub仓库依赖求助

Android项目GitHub依赖无法解析问题排查

更换系统后,Android项目中使用GitHub仓库的依赖多数无法解析,旧开发环境可正常工作,新环境出现依赖未找到错误:
错误截图

已在settings.gradle中添加maven { url 'https://jitpack.io' }配置,网络连接稳定,但问题仍未解决。以下是项目相关配置文件:

相关配置文件

app模块build.gradle

plugins {
    id 'com.android.application'
}

android {
    compileSdk 32

    defaultConfig {
        applicationId "com.sabirkhansahebsons"
        minSdk 21
        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.7.0'
    implementation 'com.google.android.material:material:1.12.0'
    implementation 'androidx.constraintlayout:constraintlayout:2.1.4'
    testImplementation 'junit:junit:4.13.2'
    androidTestImplementation 'androidx.test.ext:junit:1.2.1'
    androidTestImplementation 'androidx.test.espresso:espresso-core:3.6.1'
    implementation 'com.github.armcha:ElasticView:0.2.0'
    implementation 'com.google.firebase:firebase-storage:21.0.0'
    implementation 'com.google.firebase:firebase-auth:23.0.0'
    implementation 'androidx.legacy:legacy-support-v4:1.0.0'
    implementation 'com.google.firebase:firebase-database:21.0.0'
    implementation 'com.google.firebase:firebase-dynamic-links:22.0.0'
    testImplementation 'junit:junit:4.13.2'
    androidTestImplementation 'androidx.test.ext:junit:1.1.5'
    androidTestImplementation 'androidx.test.espresso:espresso-core:3.5.1'
    implementation 'com.hbb20:ccp:2.3.1'
    implementation 'com.google.android.material:material:1.12.0'
    implementation 'com.firebase:firebase-client-android:2.4.0'
    implementation 'com.chaos.view:pinview:1.4.3'
    implementation 'com.ismaeldivita.chipnavigation:chip-navigation-bar:1.3.2'
    implementation 'org.jetbrains.kotlin:kotlin-stdlib:1.9.20'
    implementation 'com.facebook.shimmer:shimmer:0.5.0'
    implementation 'de.hdodenhof:circleimageview:3.1.0'
    implementation 'com.github.pratikbutani:MultiSelectSpinner:f47c0dadea'
    implementation 'androidx.multidex:multidex:2.0.1'
    implementation 'io.apptik.widget:multiselectspinner:1.0.12'
    implementation 'com.github.bumptech.glide:glide:4.3.1'
    implementation 'com.github.armcha:ElasticView:0.2.0'
    implementation 'net.danlew:android.joda:2.9.5.1'
    implementation 'devs.mulham.horizontalcalendar:horizontalcalendar:1.3.4'
    implementation 'com.android.volley:volley:1.2.1'
    implementation 'com.karumi:dexter:6.2.3'
    implementation 'androidx.browser:browser:1.8.0'
    implementation 'com.ernestoyaquello.stepperform:vertical-stepper-form:2.7.0'
    implementation 'me.drozdzynski.library.steppers:steppers:1.0.0'
    implementation 'org.apache.commons:commons-collections4:4.4'
    implementation 'commons-net:commons-net:3.6'
    implementation 'org.jsoup:jsoup:1.10.2'
    implementation 'com.github.florent37:tutoshowcase:1.0.1'
    implementation('com.razorpay:checkout:1.6.20')


    //Butterknife
    implementation 'com.jakewharton:butterknife:8.8.1'
    implementation 'com.github.yalantis:ucrop:2.2.2'
    implementation 'com.google.android.play:core:1.10.3'
}

settings.gradle

pluginManagement {
    repositories {
        gradlePluginPortal()
        google()
        mavenCentral()
    }
}
dependencyResolutionManagement {
    repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS)
    repositories {
        google()
        mavenCentral()
        jcenter()
        maven { url 'https://jitpack.io' }
    }
}

rootProject.name = "SabirKhansahebSons"
include ':app'

项目根目录build.gradle

// Top-level build file where you can add configuration options common to all sub-projects/modules.
plugins {
    id 'com.android.application' version '7.2.0' apply false
    id 'com.android.library' version '7.2.0' apply false
}

task clean(type: Delete) {
    delete rootProject.buildDir
}

排查方向及解决方案

  • 移除已废弃的JCenter仓库:JCenter已停止维护,大量旧依赖已被下架,删除settings.gradle中的jcenter()配置。对于仅存在于JCenter的依赖(如com.firebase:firebase-client-android:2.4.0),替换为官方维护的新版本(Firebase当前依赖应使用com.google.firebase:firebase-database等官方库)。
  • 验证JitPack依赖可用性:
    • 检查GitHub仓库是否存在、未归档;
    • 对于使用commit哈希的依赖(f47c0dadea),确认该commit是否仍存在于仓库中;
    • 确认JitPack对应依赖的构建状态是否正常。
  • 升级Gradle及插件版本:当前Android Gradle插件7.2.0版本较旧,部分新依赖(如com.google.android.material:1.12.0)需要更高版本插件支持。建议升级插件到8.x稳定版,同时同步升级Gradle wrapper版本。
  • 清理重复依赖:app模块中存在重复依赖(如junit:junit:4.13.2、com.google.android.material:material:1.12.0),删除重复项避免解析冲突。
  • 强制刷新依赖缓存:执行命令./gradlew clean build --refresh-dependencies清除旧缓存并重新拉取所有依赖,同时检查系统是否存在代理拦截Gradle请求。
  • 补充Firebase配置:当前项目未添加Google服务插件,需在根build.gradle添加:
    plugins {
        // 原有插件
        id 'com.google.gms.google-services' version '4.4.2' apply false
    }
    
    并在app模块build.gradle末尾添加:
    apply plugin: 'com.google.gms.google-services'
    
    确保Firebase依赖正常解析。

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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.06.18 12:54:54