【问题标题】:Task failing on project build (Could not resolve all files for configuration)项目构建任务失败(无法解析所有配置文件)
【发布时间】:2020-04-27 16:09:24
【问题描述】:

我注意到这是构建应用程序时的常见问题。每次我尝试构建我的项目时,我都会收到此错误,但所有级别的 build.gradle 都与另一个项目相同,该项目的构建没有任何问题。我已经尝试以多种方式将存储库放在另一个之上,但它不起作用。我还尝试按照某些论坛的建议从 2 个不同的 Internet 连接下载,但没有运气。这是错误:

> Task :app:preDebugBuild FAILED

FAILURE: Build failed with an exception.

* What went wrong:
Could not resolve all files for configuration ':app:debugCompileClasspath'.
> Could not find com.squareup.okhttp3:okhttp:^4.2.2.
  Required by:
      project :app

请记住,以下规范与其他正在完美构建的项目相同。

Ionic:

   Ionic CLI                     : 6.6.0 (C:\Users\joelf\AppData\Roaming\nvm\v12.11.1\node_modules\@ionic\cli)
   Ionic Framework               : @ionic/angular 4.11.8
   @angular-devkit/build-angular : 0.801.3
   @angular-devkit/schematics    : 8.1.3
   @angular/cli                  : 8.1.3
   @ionic/angular-toolkit        : 2.1.2

Cordova:

   Cordova CLI       : 9.0.0 (cordova-lib@9.0.1)
   Cordova Platforms : not available
   Cordova Plugins   : cordova-plugin-ionic-keyboard 2.2.0, cordova-plugin-ionic-webview 4.1.3, (and 14 other plugins)

Utility:

   cordova-res : 0.12.2
   native-run  : 0.3.0

System:

   Android SDK Tools : 26.1.1 (C:\Users\joelf\AppData\Local\Android\Sdk\)
   NodeJS            : v12.11.1 (C:\Program Files\nodejs\node.exe)
   npm               : 6.11.3
   OS                : Windows 10

我的 gradle.build 文件看起来像这样:

如果您需要任何其他文件,请告诉我,这是我第一次使用 gradle、ionic 和 cordova,所以我有点迷失在这里,任何帮助将不胜感激,在此先感谢。

【问题讨论】:

  • 能否请您添加您的构建 gradle 应用级别
  • 它实际上列出了完整代码的链接,我将其输入错误为 'gradle.build' 而不是 'build.gradle' 哈哈抱歉,但我刚刚编辑过它就在那里。

标签: android cordova ionic-framework gradle


【解决方案1】:

请使用这个:

 implementation "com.squareup.okhttp3:okhttp:4.2.2"

而不是这个:

 implementation "com.squareup.okhttp3:okhttp:^4.2.2"

编辑:

你可以这样添加

implementation group: 'com.squareup.okhttp3', name: 'okhttp', version: '4.2.2'

要从 maven 获取依赖项,您需要将其添加到您的存储库中

repositories {
    mavenCentral()
}

【讨论】:

  • 请原谅我的问题,但是你会在哪里写这个?
  • build.gradle 应用级别
  • 即使我这样使用它,当我在模拟器中运行调试时,它也会自动更改为实现“com.squareup.okhttp3:okhttp:^4.2.2”。知道为什么吗?
  • 我什至更改了 package.json 中的 okhttp 版本,但在我的应用程序级别 build.gradle 仍然更改为 ^4.2.2。
  • 这是一种奇怪的行为!删除该行并清理您的项目,然后重新编写
猜你喜欢
  • 1970-01-01
  • 2022-08-19
  • 1970-01-01
  • 2014-10-04
  • 1970-01-01
  • 2021-05-19
  • 2016-03-17
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多