【问题标题】:Could not resolve androidx.drawerlayout:drawerlayout:1.0.0无法解析 androidx.drawerlayout:drawerlayout:1.0.0
【发布时间】:2019-04-23 17:34:01
【问题描述】:

将我的 android studio 从 3.3 更新到 3.4 后,我现在收到此错误。

ERROR: Unable to resolve dependency for ':app@debug/compileClasspath': Could not resolve androidx.drawerlayout:drawerlayout:1.0.0.
Show Details
Affected Modules: app


ERROR: Unable to resolve dependency for ':app@debug/compileClasspath': Could not resolve androidx.cursoradapter:cursoradapter:1.0.0.
Show Details
Affected Modules: app


ERROR: Unable to resolve dependency for ':app@debugAndroidTest/compileClasspath': Could not resolve androidx.drawerlayout:drawerlayout:1.0.0.
Show Details
Affected Modules: app


ERROR: Unable to resolve dependency for ':app@debugAndroidTest/compileClasspath': Could not resolve androidx.cursoradapter:cursoradapter:1.0.0.
Show Details
Affected Modules: app


ERROR: Unable to resolve dependency for ':app@debugUnitTest/compileClasspath': Could not resolve androidx.drawerlayout:drawerlayout:1.0.0.
Show Details
Affected Modules: app


ERROR: Unable to resolve dependency for ':app@debugUnitTest/compileClasspath': Could not resolve androidx.cursoradapter:cursoradapter:1.0.0.
Show Details
Affected Modules: app


ERROR: Unable to resolve dependency for ':app@release/compileClasspath': Could not resolve androidx.drawerlayout:drawerlayout:1.0.0.
Show Details
Affected Modules: app


ERROR: Unable to resolve dependency for ':app@release/compileClasspath': Could not resolve androidx.cursoradapter:cursoradapter:1.0.0.
Show Details
Affected Modules: app


ERROR: Unable to resolve dependency for ':app@releaseUnitTest/compileClasspath': Could not resolve androidx.drawerlayout:drawerlayout:1.0.0.
Show Details
Affected Modules: app


ERROR: Unable to resolve dependency for ':app@releaseUnitTest/compileClasspath': Could not resolve androidx.cursoradapter:cursoradapter:1.0.0.
Show Details
Affected Modules: app

请注意,我的项目在升级 Android Studio 之前没有问题。

为了解决这个问题,我尝试了以下方法: 1.添加两个依赖项

    implementation 'androidx.drawerlayout:drawerlayout:1.0.0'
    implementation 'androidx.cursoradapter:cursoradapter:1.0.0'

但问题仍然存在。

  1. 使缓存无效并重新启动。
  2. 清理并重建

所有这些都不起作用。

Google's Maven Repository 中列出了似乎未解决的依赖项,但 android studio 无法解决它们。我该如何解决这个问题,任何帮助将不胜感激。

【问题讨论】:

  • 你的 gradle-wrapper.properties 中的 distributionUrl 是什么?
  • distributionUrl=https\://services.gradle.org/distributions/gradle-5.1.1-all.zip
  • 然后使用以下依赖项: implementation 'androidx.drawerlayout:drawerlayout:1.0.0-alpha1' implementation 'androidx.cursoradapter:cursoradapter:1.0.0-rc02'
  • 感谢您询问我的 distributionUrl。我昨天刚刚将它从 gradle-4.10.1 升级到了 gradle-5.1.1。现在恢复后我的项目同步成功
  • 太棒了 :) 但您也可以尝试将 5.1.1 与我建议的上述网址一起使用,并让我知道它是否有效

标签: android android-gradle-plugin android-jetpack


【解决方案1】:

我通过恢复 gradle-wrapper.properties

中的 distributionUrl 解决了我的问题

来自

distributionUrl=https\://services.gradle.org/distributions/gradle-5.1.1-all.zip

返回

distributionUrl=https\://services.gradle.org/distributions/gradle-4.10.1-all.zip

并且还恢复了 build.gradle 中的 gradle 依赖 来自

        classpath 'com.android.tools.build:gradle:3.4.0'

返回

        classpath 'com.android.tools.build:gradle:3.3.2'

不过,这似乎是临时解决方案。

【讨论】:

  • 我不明白为什么我们必须降级我们的 Gradle 版本而这些错误无法修复
  • @hassanmoradnezhad 你在最新版本中遇到这个问题吗?如果不升级到最新版本,我认为它已修复。
猜你喜欢
  • 1970-01-01
  • 2013-07-24
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2016-02-26
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多