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

HMS Toolkit构建错误:无法找到com.huawei.hms:ads-identifier依赖

解决HMS构建时找不到com.huawei.hms:ads-identifier:3.4.40.300的问题
  • 确认华为Maven仓库配置正确性
    检查项目根目录的build.gradle(非app模块),确保华为仓库已添加到allprojects的repositories中:

    allprojects {
        repositories {
            google()
            mavenCentral()
            maven { url 'https://developer.huawei.com/repo/' }
        }
    }
    

    若使用Gradle 7.0及以上版本,需在settings.gradle中配置:

    dependencyResolutionManagement {
        repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS)
        repositories {
            google()
            mavenCentral()
            maven { url 'https://developer.huawei.com/repo/' }
        }
    }
    
  • 验证依赖版本有效性
    部分旧版本或测试版可能已从仓库下线,建议替换为官方稳定版。修改app模块build.gradle中的依赖:

    dependencies {
        implementation 'com.huawei.hms:ads-identifier:3.4.63.300' // 示例稳定版号,可根据实际调整
    }
    
  • 清理缓存并重新同步
    执行Gradle清理命令:

    # macOS/Linux
    ./gradlew clean
    
    # Windows
    gradlew clean
    

    完成后点击Android Studio菜单栏File -> Sync Project with Gradle Files重新同步项目。

  • 排查网络问题
    确保网络可正常访问华为Maven仓库,避免代理、防火墙或网络限制导致无法拉取依赖。

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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.08.22 09:54:14