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

Android Studio Kotlin中加载GitHub依赖失败问题求助

问题描述

尝试添加两个GitHub开源库作为项目依赖:

  • compose-audiowaveform
  • Amplituda

使用的依赖声明代码:

implementation ("com.github.lincollincol:compose-audiowaveform:1.1.2")
implementation ("com.github.lincollincol:amplituda:2.2.2")

执行同步后出现以下错误:

Could not find com.github.lincollincol:compose-audiowaveform:1.1.2.
Searched in the following locations:

  • https://dl.google.com/dl/android/maven2/com/github/lincollincol/compose-audiowaveform/1.1.2/compose-audiowaveform-1.1.2.pom
  • https://repo.maven.apache.org/maven2/com/github/lincollincol/compose-audiowaveform/1.1.2/compose-audiowaveform-1.1.2.pom
    Required by:
    project :androidApp

Could not find com.github.lincollincol:amplituda:2.2.2.
Searched in the following locations:

  • (对应Google Maven及Maven Central仓库地址)
解决方法

这类GitHub托管的开源库通常不在Google Maven或Maven Central上发布,需要添加JitPack仓库来拉取依赖:

1. 添加JitPack仓库

根据Gradle版本选择对应配置方式:

  • 新版Gradle(使用settings.gradle):
    在项目根目录的settings.gradle文件中,在仓库列表里新增JitPack地址:
dependencyResolutionManagement {
    repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS)
    repositories {
        google()
        mavenCentral()
        maven { url = uri("https://jitpack.io") }
    }
}
  • 旧版Gradle(使用根目录build.gradle):
    在根目录build.gradle的allprojects块中添加JitPack仓库:
allprojects {
    repositories {
        google()
        mavenCentral()
        maven { url "https://jitpack.io" }
    }
}

2. 核对依赖版本

确认使用的版本号在对应开源库的发布列表中存在,避免版本号拼写错误。

3. 同步项目

点击Android Studio右上角的「Sync Project with Gradle Files」按钮,重新同步项目即可。


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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.06.16 01:33:15