无法解析org.kodein.di:kodein-di-framework-android

时间:2019-05-08 09:10:58

标签: android android-gradle jcenter kodein

TL; DR

在JCenter上未经授权访问Kodein核心软件包。

详细信息

我们正在使用Kodein进行依赖项注入,但是当Gradle尝试下载任何Unauthorized工件时,JCenter服务器突然返回org.kodein.*

* What went wrong:
Could not determine the dependencies of task ':app:compileDebugJavaWithJavac'.
> Could not resolve all task dependencies for configuration ':app:debugCompileClasspath'.
> Could not resolve org.kodein.di:kodein-di-framework-android-x:6.1.0.
    Required by:
        project :app
    > Could not resolve org.kodein.di:kodein-di-framework-android-x:6.1.0.
        > Could not get resource 'https://jitpack.io/org/kodein/di/kodein-di-framework-android-x/6.1.0/kodein-di-framework-android-x-6.1.0.pom'.
            > Could not HEAD 'https://jitpack.io/org/kodein/di/kodein-di-framework-android-x/6.1.0/kodein-di-framework-android-x-6.1.0.pom'.
              Received status code 401 from server: Unauthorized
> Could not resolve org.kodein.di:kodein-di-generic-jvm:6.1.0.
    Required by:
        project :app
    > Could not resolve org.kodein.di:kodein-di-generic-jvm:6.1.0.
        > Could not get resource 'https://jitpack.io/org/kodein/di/kodein-di-generic-jvm/6.1.0/kodein-di-generic-jvm-6.1.0.pom'.
            > Could not HEAD 'https://jitpack.io/org/kodein/di/kodein-di-generic-jvm/6.1.0/kodein-di-generic-jvm-6.1.0.pom'.
              Received status code 401 from server: Unauthorized

它也被报告为issue by Kodein-DI community

是否可以从另一台服务器获取工件?

2 个答案:

答案 0 :(得分:2)

虽然未重新建立对JCenter的访问权限,但这种快速被黑客攻击可以编译项目:

allprojects {
    repositories {
        google()
        jcenter()
        maven {
            url 'http://dl.bintray.com/kotlin/kotlin-eap'
            content {
                includeGroup "org.kodein"
            }
        }
        maven { url 'https://jitpack.io' }
        maven { url 'https://dl.bintray.com/kodein-framework/Kodein-DI' }
    }
}

基本上,它会忽略JitPack中的Kodein工件,而是从Bintray下载它们

答案 1 :(得分:1)

在项目级别的build.gradle文件中添加以下代码并同步项目:

allprojects {
    repositories {
        google()
        jcenter()
        maven {url "https://jitpack.io"}
        maven { url "https://dl.bintray.com/kodein-framework/Kodein-DI" }
    }
}

Visit for More Details