【问题标题】:Build error in Gradle/Flutter: 'Could not resolve all artifacts for configuration'?Gradle/Flutter 中的构建错误:“无法解析所有工件以进行配置”?
【发布时间】:2021-07-02 10:44:11
【问题描述】:

试图构建应用程序,编译器输出如下:


FAILURE: Build failed with an exception.

* What went wrong:
A problem occurred configuring project ':app_settings'.
> Could not resolve all artifacts for configuration ':app_settings:classpath'.
   > Could not find org.jetbrains.kotlin:kotlin-gradle-plugin:1.3.70.
     Searched in the following locations:
       - https://dl.google.com/dl/android/maven2/org/jetbrains/kotlin/kotlin-gradle-plugin/1.3.70/kotlin-gradle-plugin-1.3.70.pom
     If the artifact you are trying to retrieve can be found in the repository but without metadata in 'Maven POM' format, you need to adjust the 'metadataSources { ... }' of the repository declaration.
     Required by:
         project :app_settings
   > Could not find org.jetbrains.kotlin:kotlin-stdlib-jdk8:1.3.61.
     Searched in the following locations:
       - https://dl.google.com/dl/android/maven2/org/jetbrains/kotlin/kotlin-stdlib-jdk8/1.3.61/kotlin-stdlib-jdk8-1.3.61.pom
     If the artifact you are trying to retrieve can be found in the repository but without metadata in 'Maven POM' format, you need to adjust the 'metadataSources { ... }' of the repository declaration.
     Required by:
         project :app_settings > com.android.tools.build:gradle:3.6.1
         project :app_settings > com.android.tools.build:gradle:3.6.1 > com.android.tools.build:builder:3.6.1
         project :app_settings > com.android.tools.build:gradle:3.6.1 > com.android.tools.lint:lint-gradle-api:26.6.1
         project :app_settings > com.android.tools.build:gradle:3.6.1 > com.android.tools.build:gradle-api:3.6.1
         project :app_settings > com.android.tools.build:gradle:3.6.1 > androidx.databinding:databinding-compiler-common:3.6.1
         project :app_settings > com.android.tools.build:gradle:3.6.1 > com.android.tools.build:builder:3.6.1 > com.android.tools:sdk-common:26.6.1
         project :app_settings > com.android.tools.build:gradle:3.6.1 > com.android.tools.build:builder:3.6.1 > com.android.tools:common:26.6.1
         project :app_settings > com.android.tools.build:gradle:3.6.1 > com.android.tools.build:builder:3.6.1 > com.android.tools.build:manifest-merger:26.6.1
         project :app_settings > com.android.tools.build:gradle:3.6.1 > com.android.tools.build:builder:3.6.1 > com.android.tools.analytics-library:tracker:26.6.1
         project :app_settings > com.android.tools.build:gradle:3.6.1 > com.android.tools.build:builder:3.6.1 > com.android.tools:sdklib:26.6.1 > com.android.tools:repository:26.6.1
         project :app_settings > com.android.tools.build:gradle:3.6.1 > com.android.tools.build:builder:3.6.1 > com.android.tools:sdk-common:26.6.1 > com.android.tools.analytics-library:shared:26.6.1
   > Could not find org.ow2.asm:asm:7.0.
     Searched in the following locations:
       - https://dl.google.com/dl/android/maven2/org/ow2/asm/asm/7.0/asm-7.0.pom
     If the artifact you are trying to retrieve can be found in the repository but without metadata in 'Maven POM' format, you need to adjust the 'metadataSources { ... }' of the repository declaration.
     Required by:
         project :app_settings > com.android.tools.build:gradle:3.6.1
         project :app_settings > com.android.tools.build:gradle:3.6.1 > com.android.tools.build:builder:3.6.1
   > Could not find org.ow2.asm:asm-analysis:7.0.
     Searched in the following locations:
       - https://dl.google.com/dl/android/maven2/org/ow2/asm/asm-analysis/7.0/asm-analysis-7.0.pom
     If the artifact you are trying to retrieve can be found in the repository but without metadata in 'Maven POM' format, you need to adjust the 'metadataSources { ... }' of the repository declaration.
     Required by:
         project :app_settings > com.android.tools.build:gradle:3.6.1
   > Could not find org.ow2.asm:asm-commons:7.0.
     Searched in the following locations:
       - https://dl.google.com/dl/android/maven2/org/ow2/asm/asm-commons/7.0/asm-commons-7.0.pom
     If the artifact you are trying to retrieve can be found in the repository but without metadata in 'Maven POM' format, you need to adjust the 'metadataSources { ... }' of the repository declaration.
     Required by:
         project :app_settings > com.android.tools.build:gradle:3.6.1
         project :app_settings > com.android.tools.build:gradle:3.6.1 > com.android.tools.build:builder:3.6.1
   > Could not find org.ow2.asm:asm-util:7.0.
     Searched in the following locations:
       - https://dl.google.com/dl/android/maven2/org/ow2/asm/asm-util/7.0/asm-util-7.0.pom
     If the artifact you are trying to retrieve can be found in the repository but without metadata in 'Maven POM' format, you need to adjust the 'metadataSources { ... }' of the repository declaration.
     Required by:
         project :app_settings >....

完整输出:https://pastebin.com/Vj67AWAH

我尝试删除 app_settins 插件,但它在另一个插件上失败了,所以我认为这是一个普遍问题,而不是特定于插件的问题。

我尝试重新安装不同版本的AndroidStudio,就像jdk和flutter sdk一样

我就是想不通

帮助!


编辑

这是 build.gradle:


buildscript {
    ext.kotlin_version = '1.4.31'
    repositories {
        google()
        jcenter()
    }

    dependencies {
        classpath 'com.android.tools.build:gradle:4.1.2'
        classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
    }
}

allprojects {
    repositories {
        google()
        jcenter()
    }
}

rootProject.buildDir = '../build'
subprojects {
    project.buildDir = "${rootProject.buildDir}/${project.name}"
    project.evaluationDependsOn(':app')
}

task clean(type: Delete) {
    delete rootProject.buildDir
}


【问题讨论】:

  • 更新您的 gradle 版本并打开 Android 模块并选择 Invalidate Caches/Restart from File section 。它可能有帮助
  • 不,它不会改变任何东西。
  • 您的 build.gradle 文件中有哪些存储库?你有 google() 和 jcenter() 吗?
  • 至少在主 build.gradle 中有 jcenter() 和 google()。是你要的那个吗?

标签: android flutter gradle classpath


【解决方案1】:

这可能是侥幸,但我在网上搜索时偶然发现了this

有点追随它,我删除了所有缓存的插件 user_folder>/AppData/Local/Pub/Cache/hosted/pub.dartlang.org/ 然后在项目中运行flutter pub get。

现在可以了。

如果有人知道为什么/如何工作,请解释一下,谢谢!

【讨论】:

    猜你喜欢
    • 2020-12-05
    • 1970-01-01
    • 2022-06-11
    • 1970-01-01
    • 2020-08-24
    • 2020-11-08
    • 1970-01-01
    • 2018-03-31
    • 2019-12-19
    相关资源
    最近更新 更多