任务“:app:compileFlutterBuildDebug”执行失败-flutter.gradle 行:1035
Posted
技术标签:
【中文标题】任务“:app:compileFlutterBuildDebug”执行失败-flutter.gradle 行:1035【英文标题】:Execution failed for task ':app:compileFlutterBuildDebug' - flutter.gradle line: 1035 【发布时间】:2021-08-21 00:30:22 【问题描述】:我不知道我的 Gradle 有什么问题。 我什么都试过了。
flutter pub 缓存修复 扑干净 删除 .gradle 删除 pubspec.lock
一切,但什么都没有。
我不明白可能是什么。如果有人有答案或可以帮助我,我将不胜感激
IDE:androidStudio
颤动运行 --verbose
Persisting file store
[ ] [ +18 ms] Done persisting file store
[ ] [ +1 ms] Target kernel_snapshot failed: Exception
[ ] #0 KernelSnapshot.build (package:flutter_tools/src/build_system/targets/common.dart:291:7)
[ ]
[ ] #1 _BuildInstance._invokeInternal (package:flutter_tools/src/build_system/build_system.dart:828:9)
[ ]
[ ] #2 Future.wait. (dart:async/future.dart)
[ ]
[ ] #3 _BuildInstance.invokeTarget (package:flutter_tools/src/build_system/build_system.dart:766:32)
[ ]
[ ] #4 FlutterBuildSystem.build (package:flutter_tools/src/build_system/build_system.dart:595:16)
[ ]
[ ] #5 AssembleCommand.runCommand (package:flutter_tools/src/commands/assemble.dart:318:32)
[ ]
[ ] #6 FlutterCommand.run. (package:flutter_tools/src/runner/flutter_command.dart:1043:27)
[ ]
[ ] #7 AppContext.run. (package:flutter_tools/src/base/context.dart:150:19)
[ ]
[ ] #8 CommandRunner.runCommand (package:args/command_runner.dart:196:13)
[ ]
[ ] #9 FlutterCommandRunner.runCommand. (package:flutter_tools/src/runner/flutter_command_runner.dart:284:9)
[ ]
[ ] #10 AppContext.run. (package:flutter_tools/src/base/context.dart:150:19)
[ ]
[ ] #11 FlutterCommandRunner.runCommand (package:flutter_tools/src/runner/flutter_command_runner.dart:232:5)
[ ]
[ ] #12 run.. (package:flutter_tools/runner.dart:62:9)
[ ]
[ ] #13 AppContext.run. (package:flutter_tools/src/base/context.dart:150:19)
[ ]
[ ] #14 main (package:flutter_tools/executable.dart:91:3)
[ ]
[ ] [ +3 ms]
[ ] #0 throwToolExit (package:flutter_tools/src/base/common.dart:10:3)
[ ] #1 AssembleCommand.runCommand (package:flutter_tools/src/commands/assemble.dart:335:7)
[ ]
[ ] #2 FlutterCommand.run. (package:flutter_tools/src/runner/flutter_command.dart:1043:27)
[ ]
[ ] #3 AppContext.run. (package:flutter_tools/src/base/context.dart:150:19)
[ ]
[ ] #4 CommandRunner.runCommand (package:args/command_runner.dart:196:13)
[ ]
[ ] #5 FlutterCommandRunner.runCommand. (package:flutter_tools/src/runner/flutter_command_runner.dart:284:9)
[ ]
[ ] #6 AppContext.run. (package:flutter_tools/src/base/context.dart:150:19)
[ ]
[ ] #7 FlutterCommandRunner.runCommand (package:flutter_tools/src/runner/flutter_command_runner.dart:232:5)
[ ]
[ ] #8 run.. (package:flutter_tools/runner.dart:62:9)
[ ]
[ ] #9 AppContext.run. (package:flutter_tools/src/base/context.dart:150:19)
[ ]
[ ] #10 main (package:flutter_tools/executable.dart:91:3)
[ ]
[ ] [ +8 ms] "flutter assemble" took 14.376ms.
[ +76 ms] [ +118 ms] ensureAnalyticsSent: 117ms
[ ] [ +1 ms] Running shutdown hooks
[ ] [ ] Shutdown hooks complete
[ ] [ ] exiting with code 1
[ +69 ms] > Task :app:compileFlutterBuildDebug FAILED
[ ] Deprecated Gradle features were used in this build, making it incompatible with Gradle 7.0.
[ ] Use '--warning-mode all' to show the individual deprecation warnings.
[ ] See https://docs.gradle.org/6.7/userguide/command_line_interface.html#sec:command_line_warnings
[ ] 1 actionable task: 1 executed
[ ] FAILURE: Build failed with an exception.
[ ] * Where:
[ ] Script 'C:\Users\jeron\Downloads\flutter\packages\flutter_tools\gradle\flutter.gradle' line: 1035
[ ] * What went wrong:
[ ] Execution failed for task ':app:compileFlutterBuildDebug'.
[ ] > Process 'command 'C:\Users\jeron\Downloads\flutter\bin\flutter.bat'' finished with non-zero exit value 1
[ ] * 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 17s
[ +335 ms] Running Gradle task 'assembleDebug'... (completed in 18,4s)
[ +2 ms] Exception: Gradle task assembleDebug failed with exit code 1
[ +1 ms] "flutter run" took 19.233ms.
[ +2 ms]
#0 throwToolExit (package:flutter_tools/src/base/common.dart:10:3)
#1 RunCommand.runCommand (package:flutter_tools/src/commands/run.dart:663:9)
#2 FlutterCommand.run. (package:flutter_tools/src/runner/flutter_command.dart:1043:27)
#3 AppContext.run. (package:flutter_tools/src/base/context.dart:150:19)
#4 CommandRunner.runCommand (package:args/command_runner.dart:196:13)
#5 FlutterCommandRunner.runCommand. (package:flutter_tools/src/runner/flutter_command_runner.dart:284:9)
#6 AppContext.run. (package:flutter_tools/src/base/context.dart:150:19)
#7 FlutterCommandRunner.runCommand (package:flutter_tools/src/runner/flutter_command_runner.dart:232:5)
#8 run.. (package:flutter_tools/runner.dart:62:9)
#9 AppContext.run. (package:flutter_tools/src/base/context.dart:150:19)
#10 main (package:flutter_tools/executable.dart:91:3)
[ +114 ms] ensureAnalyticsSent: 113ms
[ +1 ms] Running shutdown hooks
[ ] Shutdown hooks complete
[ ] exiting with code 1
颤振医生-v
[√] Flutter (Channel stable, 2.2.1, on Microsoft Windows [Versión 10.0.18363.1500], locale es-AR)
• Flutter version 2.2.1 at C:\Users\jeron\Downloads\flutter
• Framework revision 02c026b (6 days ago), 2021-05-27 12:24:44 -0700
• Engine revision 0fdb562ac8
• Dart version 2.13.1
[√] Android toolchain - develop for Android devices (Android SDK version 30.0.2)
• Android SDK at C:\Users\jeron\AppData\Local\Android\Sdk
• Platform android-30, build-tools 30.0.2
• ANDROID_HOME = C:\Users\jeron\AppData\Local\Android\Sdk
• Java binary at: F:\Android\jre\bin\java
• Java version OpenJDK Runtime Environment (build 11.0.8+10-b944.6842174)
• All Android licenses accepted.
[√] Chrome - develop for the web
• Chrome at C:\Program Files (x86)\Google\Chrome\Application\chrome.exe
[!] Visual Studio - develop for Windows (Visual Studio Community 2019 16.7.1)
• Visual Studio at C:\Program Files (x86)\Microsoft Visual Studio\2019\Community
• Visual Studio Community 2019 version 16.7.30406.217
X Visual Studio is missing necessary components. Please re-run the Visual Studio installer for the "Desktop development with C++" workload, and include these components:
MSVC v142 - VS 2019 C++ x64/x86 build tools
- If there are multiple build tool versions available, install the latest
C++ CMake tools for Windows
Windows 10 SDK
[√] Android Studio (version 4.1.0)
• Android Studio at F:\Android
• 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.8+10-b944.6842174)
[√] Connected device (4 available)
• sdk gphone x86 arm (mobile) • emulator-5554 • android-x86 • Android 11 (API 30) (emulator)
• Windows (desktop) • windows • windows-x64 • Microsoft Windows [Versión 10.0.18363.1500]
• Chrome (web) • chrome • web-javascript • Google Chrome 90.0.4430.212
• Edge (web) • edge • web-javascript • Microsoft Edge 90.0.818.46
! Doctor found issues in 1 category.
我的 pubspec.yaml
name: untitled
description: A new Flutter project.
environment:
sdk: ">=2.12.0 <3.0.0"
dependencies:
flutter:
sdk: flutter
cupertino_icons: ^1.0.0
url_launcher: ^6.0.3
shared_preferences: ^2.0.5
rxdart: ^0.26.0
image_picker: ^0.7.4
auto_size_text: ^3.0.0-nullsafety.0
sticky_headers: ^0.2.0
intl: ^0.17.0
image: ^3.0.2
path_provider: ^2.0.1
permission_handler: ^6.1.3
image_cropper: ^1.4.0
cached_network_image: ^3.0.0
scoped_model: ^2.0.0-nullsafety.0
camera: ^0.8.1
share: ^2.0.1
flip_card: ^0.5.0
fluttertoast: ^8.0.6
flutter_masked_text2: ^0.9.1
syncfusion_flutter_sliders: ^19.1.58-beta
flutter_swiper_null_safety: ^1.0.1
flutter_sms: ^2.3.1
local_auth: ^1.1.4
google_maps_flutter: ^2.0.3
webview_flutter: ^2.0.4
barcode_scan2: ^4.1.3
contacts_service: ^0.6.1
carousel_slider: ^4.0.0-nullsafety.0
table_calendar: ^3.0.0
photo_view: ^0.11.1
flutter_svg: ^0.21.0-nullsafety.0
qr_mobile_vision: ^3.0.0
animate_do: ^2.0.0
flutter_exif_rotation: ^0.4.1
app_settings: ^4.1.0
geolocator: ^7.0.3
file_picker: ^3.0.1
dashed_circle: ^0.0.2
geocoding: ^2.0.0
flutter_slidable: ^0.6.0
firebase_dynamic_links: ^2.0.1
firebase_core: ^1.0.4
firebase_messaging: ^9.1.3
firebase_auth: ^1.1.1
firebase_analytics: ^8.0.1
cloud_firestore: ^1.0.6
facebook_app_events: ^0.12.0
screenshot: ^1.0.0-nullsafety.1
flutter_html: ^2.0.0-nullsafety.0
collection: ^1.15.0-nullsafety.4
dev_dependencies:
flutter_test:
sdk: flutter
build_runner: ^2.0.4
json_serializable: ^4.1.3
flutter:
uses-material-design: true
gradle-wrapper.properties
#Fri Jun 23 08:50:38 CEST 2017
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
app/build.gradle
def localProperties = new Properties()
def localPropertiesFile = rootProject.file('local.properties')
if (localPropertiesFile.exists())
localPropertiesFile.withReader('UTF-8') reader ->
localProperties.load(reader)
def flutterRoot = localProperties.getProperty('flutter.sdk')
if (flutterRoot == null)
throw new GradleException("Flutter SDK not found. Define location with flutter.sdk in the local.properties file.")
def flutterVersionCode = localProperties.getProperty('flutter.versionCode')
if (flutterVersionCode == null)
throw new GradleException("versionCode not found. Define flutter.versionCode in the local.properties file.")
def flutterVersionName = localProperties.getProperty('flutter.versionName')
if (flutterVersionName == null)
throw new GradleException("versionName not found. Define flutter.versionName in the local.properties file.")
apply plugin: 'com.android.application'
apply plugin: 'kotlin-android'
apply from: "$flutterRoot/packages/flutter_tools/gradle/flutter.gradle"
def keystoreProperties = new Properties()
def keystorePropertiesFile = rootProject.file('key.properties')
if (keystorePropertiesFile.exists())
keystoreProperties.load(new FileInputStream(keystorePropertiesFile))
android
compileSdkVersion 30
sourceSets
main.java.srcDirs += 'src/main/kotlin'
compileOptions
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
lintOptions
disable 'InvalidPackage'
checkReleaseBuilds false
defaultConfig
applicationId "com.example.untitled"
minSdkVersion 21
targetSdkVersion 30
versionCode flutterVersionCode.toInteger()
versionName flutterVersionName
multiDexEnabled true
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
signingConfigs
release
keyAlias keystoreProperties['keyAlias']
keyPassword keystoreProperties['keyPassword']
storeFile file(keystoreProperties['storeFile'])
storePassword keystoreProperties['storePassword']
buildTypes
release
signingConfig signingConfigs.release
flutter
source '../..'
dependencies
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
testImplementation 'junit:junit:4.12'
androidTestImplementation 'androidx.test:runner:1.1.1'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.1.1'
implementation 'com.google.firebase:firebase-core:17.2.1'
implementation 'com.google.android.gms:play-services-basement:17.0.0'
implementation 'com.google.android.gms:play-services-tasks:17.0.0'
implementation 'com.google.android.gms:play-services-base:17.0.0'
implementation'com.google.firebase:firebase-auth:16.1.0'
implementation 'com.facebook.android:facebook-android-sdk:[5,6)'
implementation 'com.google.android.gms:play-services-vision:20.1.1'
implementation 'com.google.android.gms:play-services-vision-common:19.1.1'
apply plugin: 'com.google.gms.google-services'
build.gradle
buildscript
ext.kotlin_version = '1.3.50'
repositories
google()
jcenter()
mavenCentral()
dependencies
classpath 'com.android.tools.build:gradle:4.1.0'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
classpath 'com.google.gms:google-services:4.3.3'
allprojects
repositories
google()
jcenter()
rootProject.buildDir = '../build'
subprojects
project.buildDir = "$rootProject.buildDir/$project.name"
project.evaluationDependsOn(':app')
task clean(type: Delete)
delete rootProject.buildDir
谢谢
【问题讨论】:
尝试禁用dart.dev/null-safety/unsound-null-safety上提到的声音空安全性 @jeronimo 你找到解决办法了吗? 这能回答你的问题吗? how to solve Execution failed for task ':app:compileFlutterBuildDebug' 【参考方案1】:我认为您使用的是颤振最新版本。 该应用程序使用以下版本运行:
dart: ">=2.4.0 <3.0.0"
flutter: ">=1.12.13+hotfix.4 <2.0.0"
【讨论】:
请添加更多详细信息以扩展您的答案,例如工作代码或文档引用。【参考方案2】:将项目中使用的包升级到最新版本。我试过了,我得到了构建。
【讨论】:
以上是关于任务“:app:compileFlutterBuildDebug”执行失败-flutter.gradle 行:1035的主要内容,如果未能解决你的问题,请参考以下文章