gradle 如何从maven repository下载工件

a7qyws3x  于 5个月前  发布在  Maven
关注(0)|答案(1)|浏览(82)

我正在为我的React-Native应用程序开发一个Native-Module,让我们称之为MyModule。我想将Android库添加到MyModule。库的所有者为我提供了URL和凭据:

maven {
            url 'url'
            credentials {
                username 'username'
                password 'password'
            }
        }

字符串
所有者说将其添加到我的项目的build.gradle下。我需要将其添加到根项目(将使用MyModule)gradle下还是MyModule的gradle中?我试图将其添加到MyModule的gradle中的repositories下,但我一直得到一个错误:

Could not determine the dependencies of task ':app:processDebugResources'.
> Could not resolve all task dependencies for configuration ':app:debugRuntimeClasspath'.
   > Could not find any matches for ******* as no versions of ******* are available.
     Searched in the following locations:
       - file:/Users/**/Workspace/***/**/***/node_modules/react-native/android/**/**/**/maven-metadata.xml
       - file:/Users/****/Workspace/***/***/***/node_modules/jsc-android/dist/com/***/***/maven-metadata.xml
       - https://repo.maven.apache.org/maven2/com/***/***/maven-metadata.xml
       - https://dl.google.com/dl/android/maven2/com/***/****/maven-metadata.xml
       - https://maven.google.com/com/****/***/maven-metadata.xml
       - https://www.jitpack.io/com/***/****/maven-metadata.xml
       - https://jitpack.io/com/****/***/maven-metadata.xml
       - https://dl.anagog.com/android/public/com/***/****/maven-metadata.xml
     Required by:
         project :app > project :my-module-react-native

Possible solution:
 - Declare repository providing the artifact, see the documentation at https://docs.gradle.org/current/userguide/declaring_repositories.html


什么是正确的地方添加此URL,以便它可以下载它?

bzzcjhmw

bzzcjhmw1#

如果你需要访问私有工件仓库,你必须在你的模块(MyModule)中定义它,如下所示(文档):

repositories {
  maven {
    url = uri("link")
    credentials {
      username = "user"
      password = "password"
    }
  }
}

字符串
因此,必须在每个模块中定义存储库。您也可以在根级别上定义它,但在allprojects{}subprojects{}块中,因为它们将应用于所有模块。类似于mapbox的此代码
如果你正确配置了你的仓库,它应该列在下面一行说:“在以下位置搜索:“
如果这个仓库在列表中,但是你的依赖项仍然没有得到解决,请仔细检查你的依赖项坐标,依赖项可能是错误的,或者是仓库端的一些其他错误配置。

相关问题