flutter - Fluuter build apk:无法解析配置“:classpath”的所有工件
问题描述
我刚才安装了flutter,但是当我想运行flutter项目时出现这个错误:
Building with sound null safety
FAILURE: Build failed with an exception.
* What went wrong:
A problem occurred configuring root project 'android'.
> Could not resolve all artifacts for configuration ':classpath'.
> Could not find com.android.tools.build:gradle:4.1.0.
Searched in the following locations:
- https://dl.google.com/dl/android/maven2/com/android/tools/build/gradle/4.1.0/gradle-4.1.0.pom
- https://jcenter.bintray.com/com/android/tools/build/gradle/4.1.0/gradle-4.1.0.pom
Required by:
project :
* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.
* Get more help at https://help.gradle.org
BUILD FAILED in 5s
Running Gradle task 'assembleRelease'...
Running Gradle task 'assembleRelease'... Done 6.9s
Gradle task assembleRelease failed with exit code 1
解决方案
发布您的构建 gradle 文件。很可能您 classpath 'com.android.tools.build:gradle:4.1.0
在错误的位置添加。它应该被添加到android/build.gradle
而不是android/app/build.gradle
应该是这样的:
dependencies {
classpath 'com.android.tools.build:gradle:4.1.0'
.
.
.
}