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

Android:Gradle依赖解析失败,需保留Jitpack仓库求助

Fixing "Failed to resolve com.android.support.appcompat" When Using Jitpack Repository

Hey there, let's work through this dependency resolution issue with Jitpack step by step—no need to swap Jitpack for maven.google(), we can get this working as is.

First, double-check your Jitpack repository setup, since this is where a lot of folks trip up:

  • Make sure you've added Jitpack to the project-level build.gradle (not the module one), and place it in the right order relative to other repos:
    allprojects {
        repositories {
            google()
            jcenter() // Optional, but some older libraries still rely on it
            maven { url 'https://jitpack.io' }
        }
    }
    
    Don't put Jitpack in the buildscript block— that's for Gradle plugins, not your app's dependencies.

Next, confirm you're declaring the target library correctly in your module's build.gradle. It should follow the Jitpack format:

dependencies {
    implementation 'com.github.[RepoOwner]:[RepoName]:[VersionTag]'
}

Head to the library's GitHub repo to grab the exact release tag or commit hash if you're using a specific build—using a wrong version string can break dependency resolution too.

Now, for the Failed to resolve com.android.support.appcompat error specifically, here are the most common fixes:

  • Force a unified support library version: The issue often happens when the Jitpack library depends on a different support library version than your project. To fix this, add a resolution strategy in your module's build.gradle to force all dependencies to use your project's support version:

    configurations.all {
        resolutionStrategy {
            // Replace with the support version your project uses
            force 'com.android.support:appcompat-v7:28.0.0'
        }
    }
    

    This overrides any conflicting versions from the Jitpack library and ensures Gradle pulls the correct, consistent version.

  • Enable Jetifier if using AndroidX: If your project has migrated to AndroidX, the old support library references from the Jitpack library will cause conflicts. Enable Jetifier in your gradle.properties to auto-convert those references to AndroidX equivalents:

    android.useAndroidX=true
    android.enableJetifier=true
    
  • Check Jitpack build logs: Sometimes the problem is on Jitpack's end—maybe the library failed to build properly there. Go to the library's Jitpack page, look up the version you're trying to use, and check the build logs for errors. If the build failed, you might need to fork the repo, fix the dependency issues in your fork, then use Jitpack to pull your forked version.

Finally, clear your Gradle cache and rebuild to rule out cached issues:

# On macOS/Linux
./gradlew clean build --refresh-dependencies

# On Windows
gradlew clean build --refresh-dependencies

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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.05.19 09:56:39