[我在flutter项目的第一次运行中收到错误! `完成错误:Gradle任务assembleDebug失败,退出代码为1`

问题描述 投票:0回答:1

今天我开始学习颤动。

[我从Android Studio 3.5.3中的Flutter Application创建了新的Flutter项目,

我创建了新的android虚拟设备,然后尝试运行main.dart

[我记得我的项目在第一次运行时初始化gradle期间冻结了,所以我不得不停止并重新运行main.dart,之后它引发了以下错误:

Launching lib\main.dart on AOSP on IA Emulator in debug mode...
Running Gradle task 'assembleDebug'...

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 sdk-common.jar (com.android.tools:sdk-common:26.5.0).
     Searched in the following locations:
         https://dl.google.com/dl/android/maven2/com/android/tools/sdk-common/26.5.0/sdk-common-    26.5.0.jar

* 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 2s
Finished with error: Gradle task assembleDebug failed with exit code 1

build.gradle文件包含:

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

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

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

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

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

settings.gradle包含:

include ':app'

def flutterProjectRoot = rootProject.projectDir.parentFile.toPath()

def plugins = new Properties()
def pluginsFile = new File(flutterProjectRoot.toFile(), '.flutter-plugins')
if (pluginsFile.exists()) {
    pluginsFile.withReader('UTF-8') { reader -> plugins.load(reader) }
}

plugins.each { name, path ->
    def pluginDirectory = flutterProjectRoot.resolve(path).resolve('android').toFile()
    include ":$name"
    project(":$name").projectDir = pluginDirectory
}

我猜冻结是由于初始化时连接不良,并且sdk-common.jar没有正确下载。

如上所述,我是新手,我不知道如何清理构建项目,所以我一步一步地重复了几次,但是错误仍然存​​在。

我不知道这个问题。谁能帮助我?

如果细节不清楚,请告诉我。

android-studio flutter android-emulator
1个回答
0
投票
  • 出了什么问题:配置根项目“ android”时发生问题。无法解析配置':classpath'的所有工件。找不到sdk-common.jar(com.android.tools:sdk-common:26.5.0)。

将Maven添加到您的gradle文件中以解决此问题,如下所示>>

maven { url 'https://maven.google.com' }

尽管我建议您使用API​​ 28

我不知道如何清理构建项目

在项目根文件夹中运行flutter clean

© www.soinside.com 2019 - 2024. All rights reserved.