【问题标题】:Github package not found during build构建期间找不到 Github 包
【发布时间】:2020-09-28 10:11:54
【问题描述】:

我添加了一个我自己的 Github 包作为我的 Android Studio 项目的依赖项。当我执行 Gradle 同步时,一切似乎都很好,没有错误。但是,下次我运行“重建项目”时,出现以下错误:

Could not determine the dependencies of task ':app:processReleaseResources'.
Could not resolve all task dependencies for configuration ':app:releaseRuntimeClasspath'.
Could not find <my_config_properties_reader_package>:1.0.7.
Searched in the following locations:
 - https://dl.google.com/dl/android/maven2/<my_config_properties_reader>/1.0.7/config_properties_reader_android-1.0.7.pom
 - https://jcenter.bintray.com/<my_config_properties_reader>/1.0.7/config_properties_reader_android-1.0.7.pom
Required by:
   project :app > project :identity_provider_access

包中的类和接口可以毫无问题地导入,但我无法成功运行构建。 有谁知道这是什么?

【问题讨论】:

  • 这个 Github 包是私有仓库还是公共仓库?
  • 这是一个私人仓库

标签: android gradle package publish


【解决方案1】:

我遇到了同样的问题。 我创建了一个带有应用程序和模块的项目,该项目使用了另一个 github 包。 在构建应用程序时,我遇到了同样的错误。

最后我的项目结构如下

project
   app
   module_project
      module_dependency

对我来说,它有助于将依赖模块 (module_dependency) 的 github 存储库添加到我的应用程序的 gradle 中。用户凭据是从位于项目正下方的文件“github.properties”中检索的。

def githubProperties = new Properties()
githubProperties.load(new FileInputStream(rootProject.file("github.properties")))

repositories {
    maven {
        name = "GitHubPackages"
        url = uri("uri_module_dependency")
        credentials {
            username = githubProperties['gpr.usr'] ?: System.getenv("GPR_USER")
            password = githubProperties['gpr.key'] ?: System.getenv("GPR_API_KEY")
        }
    }
}

文件如下:

gpr.usr=your github account user name
gpr.key=your created github personal access token

【讨论】:

  • 我们可以使用 repo 的 GITHUB_TOKEN 而不是硬编码 gpr 密钥吗?
猜你喜欢
  • 1970-01-01
  • 2018-01-11
  • 2018-08-31
  • 2019-05-26
  • 2017-11-12
  • 1970-01-01
  • 1970-01-01
  • 2011-09-04
  • 1970-01-01
相关资源
最近更新 更多