android - 添加华为套件报错 "Could not find com.huawei.hms:location:6.0.0.302"

标签 android android-studio maven gradle huawei-mobile-services

正在关注 agc-get-started-android并且有

项目级build.gradle:

buildscript {
    repositories {
        google()
        mavenCentral()
        maven {url 'https://developer.huawei.com/repo/'}
    }
    dependencies {
        classpath "com.android.tools.build:gradle:7.0.3"
        classpath 'com.huawei.agconnect:agcp:1.6.0.300'

    }
}

应用模块build.gradle:

plugins {
    id 'com.android.application'
    id 'com.huawei.agconnect'
}
...
dependencies {
    ...
    implementation 'com.huawei.hms:location:6.0.0.302'
}

Gradle 构建以以下错误结束:

Execution failed for task ':app:checkDebugAarMetadata'.
> Could not resolve all files for configuration ':app:debugRuntimeClasspath'.
> Could not find com.huawei.hms:location:6.0.0.302.
 Searched in the following locations:
   - https://dl.google.com/dl/android/maven2/com/huawei/hms/location/6.0.0.302/location-6.0.0.302.pom
   - https://repo.maven.apache.org/maven2/com/huawei/hms/location/6.0.0.302/location-6.0.0.302.pom
   - https://jcenter.bintray.com/com/huawei/hms/location/6.0.0.302/location-6.0.0.302.pom
 Required by:
     project :app

我的问题的解决方案是什么?

最佳答案

你可以关注this docs整合。

添加 AppGallery Connect 插件和 Maven 存储库。

  • 进入buildscript > repositories,配置HMS Core SDK的Maven仓库地址。
  • 进入allprojects > repositories,配置HMS Core SDK的Maven仓库地址。
  • 如果 agconnect-services.json 文件已添加到应用程序,请转到 buildscript > dependencies 并添加 AppGallery Connect 插件配置。
buildscript {
    repositories {
        google()
        jcenter()
        // Configure the Maven repository address for the HMS Core SDK.
        maven {url 'https://developer.huawei.com/repo/'}
    }
    dependencies {
        ...
        // Add the AppGallery Connect plugin configuration. You are advised to use the latest plugin version.
        classpath 'com.huawei.agconnect:agcp:1.6.0.300'
    }
}

allprojects {
    repositories {
        google()
        jcenter()
        // Configure the Maven repository address for the HMS Core SDK.
        maven {url 'https://developer.huawei.com/repo/'}
    }
} 

在 Gradle 7.0 或更高版本中,allprojects > repositories 下的配置被迁移到项目级别的 settings.gradle 文件中。

settings.gradle文件的配置示例如下:

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

关于android - 添加华为套件报错 "Could not find com.huawei.hms:location:6.0.0.302",我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/69816854/

相关文章:

android - 如何将 WCP 1252 字符串读入 std::tstring?

android - 如何在 Android Lollipop 中保存 WebView 状态并恢复它?

android - ImageView 上的 setPadding 崩溃 Activity

android - 中断构建流程,并在Gradle Android Studio中包含任务

java - 如何从 java docker 容器应用程序解析文件

java - 添加aspectJ语言来定义连接点

java.lang.RuntimeException : It looks like you are using EventBus on Android, 确保将 "eventbus"Android 库添加到您的依赖项

java - 如何在整个应用程序 session 的 Activity 中仅显示一次插页式广告

javascript - Selenium 将哈希添加到 findElement

android - 使用 Android Studio 进行应用内购买时无法找到 IInAppBillingService