我刚刚创建了一个新的 flutter 应用程序,当我尝试在模拟器上运行它时出现此错误消息:
在调试模式下在为 x86 构建的 Android SDK 上启动 lib\main.dart... 运行 Gradle 任务“assembleDebug”... 失败:构建失败,出现异常。
- 出了什么问题: 任务 ':app:validateSigningDebug' 执行失败。 java.util.concurrent.ExecutionException:com.android.builder.utils.SynchronizedFile$ActionExecutionException:java.io.IOException:com.android.ide.common.signing.KeytoolException:创建密钥库失败。
- 尝试: 使用 --stacktrace 选项运行以获取堆栈跟踪。使用 --info 或 --debug 选项运行以获得更多日志输出。使用 --scan 运行以获得完整的见解。
- 在 https://help.gradle.org 获得更多帮助 6 秒内构建失败 异常:Gradle 任务 assembleDebug 失败,退出代码为 1
这是我的
build.gradle
buildscript {
ext.kotlin_version = '1.5.10'
repositories {
google()
mavenCentral()
}
dependencies {
classpath 'com.android.tools.build:gradle:4.1.0'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
}
}
allprojects {
repositories {
google()
mavenCentral()
}
}
rootProject.buildDir = '../build'
subprojects {
project.buildDir = "${rootProject.buildDir}/${project.name}"
project.evaluationDependsOn(':app')
}
task clean(type: Delete) {
delete rootProject.buildDir
}
这是我的
gradle.properties
org.gradle.jvmargs=-Xmx1536M
android.useAndroidX=true
android.enableJetifier=true
还有我的
gradle-wrapper.properties
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-6.7-all.zip
还有
flutter doctor -v
结果:
PS D:\flutter_apps\angila\flutter_application_4> flutter doctor
Doctor summary (to see all details, run flutter doctor -v):
[√] Flutter (Channel stable, 2.5.2, on Microsoft Windows [Version 10.0.19042.631], locale ar-YE)
[√] Android toolchain - develop for Android devices (Android SDK version 31.0.0)
[√] Chrome - develop for the web
[√] Android Studio (version 2020.3)
[√] Android Studio
[√] VS Code (version 1.62.1)
[√] Connected device (3 available)
• No issues found!
PS D:\flutter_apps\angila\flutter_application_4> flutter doctor -v
[√] Flutter (Channel stable, 2.5.2, on Microsoft Windows [Version 10.0.19042.631], locale ar-YE)
• Flutter version 2.5.2 at C:\src\flutter
• Upstream repository https://github.com/flutter/flutter.git
• Framework revision 3595343e20 (6 weeks ago), 2021-09-30 12:58:18 -0700
• Engine revision 6ac856380f
• Dart version 2.14.3
[√] Android toolchain - develop for Android devices (Android SDK version 31.0.0)
• Android SDK at C:\src\Sdk
• Platform android-31, build-tools 31.0.0
• ANDROID_HOME = C:\src\Sdk
• Java binary at: C:/Program Files/Android/Android Studio\jre\bin\java
• Java version OpenJDK Runtime Environment (build 11.0.10+0-b96-7249189)
• All Android licenses accepted.
[√] Chrome - develop for the web
• Chrome at C:\Program Files\Google\Chrome\Application\chrome.exe
[√] Android Studio (version 2020.3)
• Android Studio at C:\Program Files\Android\Android Studio
• Flutter plugin can be installed from:
https://plugins.jetbrains.com/plugin/9212-flutter
• Dart plugin can be installed from:
https://plugins.jetbrains.com/plugin/6351-dart
• Java version OpenJDK Runtime Environment (build 11.0.10+0-b96-7249189)
[√] Android Studio
• Android Studio at C:/Program Files/Android/Android Studio
• Flutter plugin can be installed from:
https://plugins.jetbrains.com/plugin/9212-flutter
• Dart plugin can be installed from:
https://plugins.jetbrains.com/plugin/6351-dart
• android-studio-dir = C:/Program Files/Android/Android Studio
• Java version OpenJDK Runtime Environment (build 11.0.10+0-b96-7249189)
[√] VS Code (version 1.62.1)
• VS Code at C:\Users\Abdullah\AppData\Local\Programs\Microsoft VS Code
• Flutter extension version 3.28.0
[√] Connected device (3 available)
• sdk gphone x86 64 (mobile) • emulator-5554 • android-x64 • Android 11 (API 30) (emulator)
• Chrome (web) • chrome • web-javascript • Google Chrome 95.0.4638.69
• Edge (web) • edge • web-javascript • Microsoft Edge 95.0.1020.44
• No issues found!
这是一个新应用程序,我没有在我的应用程序中进行 Google 登录。此外,在 Android Studio 或 VS Code 之前以及在其中创建和调试的每个新应用程序和旧应用程序中都会发生此错误。格式化我的电脑并重新安装 windows 后出现此错误。
问题已通过以下步骤解决:
我是 Windows 用户,所以这些步骤适用于 Windows。