在运行flutter应用程序时,遇到以下错误,该错误显示已用代码1退出flutter gradle。
我遇到了另一个随机错误,解决该错误后,我遇到了以下错误,在进行谷歌搜索之后,我发现损坏的pubspec.yaml文件是这里的罪魁祸首,但我找不到引起错误的原因。
这是我的pubspec.yaml文件
description: A new Flutter application.
# The following defines the version and build number for your application.
# A version number is three numbers separated by dots, like 1.2.43
# followed by an optional build number separated by a +.
# Both the version and the builder number may be overridden in flutter
# build by specifying --build-name and --build-number, respectively.
# In Android, build-name is used as versionName while build-number used as versionCode.
# Read more about Android versioning at https://developer.android.com/studio/publish/versioning
# In iOS, build-name is used as CFBundleShortVersionString while build-number used as CFBundleVersion.
# Read more about iOS versioning at
# https://developer.apple.com/library/archive/documentation/General/Reference/InfoPlistKeyReference/Articles/CoreFoundationKeys.html
version: 1.0.0+5
environment:
sdk: ">=2.1.0 <3.0.0"
dependencies:
flutter:
sdk: flutter
flutter_launcher_icons:
flutter_icons:
image_path:"Icons/pop-up.png"
android:true
ios:true
# The following adds the Cupertino Icons font to your application.
# Use with the CupertinoIcons class for iOS style icons.
cupertino_icons: ^0.1.2
connectivity:
dev_dependencies:
flutter_test:
sdk: flutter
firebase_auth:
gradient_widgets:
connectivity:
rxdart:
shimmer:
transparent_image:
cached_network_image:
firebase_core:
camera:
flutter_search_bar:
image_cropper:
image_picker:
firebase_database:
cloud_firestore:
firebase_messaging: '5.1.2'
shared_preferences:
firebase_storage:
# For information on the generic Dart part of this file, see the
# following page: https://dart.dev/tools/pub/pubspec
# The following section is specific to Flutter.
flutter:
# The following line ensures that the Material Icons font is
# included with your application, so that you can use the icons in
# the material Icons class.
uses-material-design: true
# To add assets to your application, add an assets section, like this:
# assets:
# - images/a_dot_burr.jpeg
# - images/a_dot_ham.jpeg
# An image asset can refer to one or more resolution-specific "variants", see
# https://flutter.dev/assets-and-images/#resolution-aware.
# For details regarding adding assets from package dependencies, see
# https://flutter.dev/assets-and-images/#from-packages
# To add custom fonts to your application, add a fonts section here,
# in this "flutter" section. Each entry in this list should have a
# "family" key with the font family name, and a "fonts" key with a
# list giving the asset and other descriptors for the font. For
# example:
# fonts:
# - family: Schyler
# fonts:
# - asset: fonts/Schyler-Regular.ttf
# - asset: fonts/Schyler-Italic.ttf
# style: italic
# - family: Trajan Pro
# fonts:
# - asset: fonts/TrajanPro.ttf
# - asset: fonts/TrajanPro_Bold.ttf
# weight: 700
#
# For details regarding fonts from package dependencies,
# see https://flutter.dev/custom-fonts/#from-packages
运行'flutter run -v'后,出现以下错误
Gradle task assembleDebug failed with exit code 1
#0 throwToolExit (package:flutter_tools/src/base/common.dart:28:3)
#1 _buildGradleProjectV2 (package:flutter_tools/src/android/gradle.dart:507:5)
<asynchronous suspension>
#2 buildGradleProject (package:flutter_tools/src/android/gradle.dart:346:14)
<asynchronous suspension>
#3 buildApk (package:flutter_tools/src/android/apk.dart:34:9)
<asynchronous suspension>
#4 AndroidDevice.startApp (package:flutter_tools/src/android/android_device.dart:426:13)
<asynchronous suspension>
#5 FlutterDevice.runHot (package:flutter_tools/src/resident_runner.dart:371:54)
<asynchronous suspension>
#6 HotRunner.run (package:flutter_tools/src/run_hot.dart:251:39)
<asynchronous suspension>
#7 RunCommand.runCommand (package:flutter_tools/src/commands/run.dart:469:37)
<asynchronous suspension>
#8 FlutterCommand.verifyThenRunCommand (package:flutter_tools/src/runner/flutter_command.dart:478:18)
<asynchronous suspension>
#9 FlutterCommand.run.<anonymous closure> (package:flutter_tools/src/runner/flutter_command.dart:383:33)
<asynchronous suspension>
#10 AppContext.run.<anonymous closure> (package:flutter_tools/src/base/context.dart:153:29)
<asynchronous suspension>
#11 _rootRun (dart:async/zone.dart:1124:13)
#12 _CustomZone.run (dart:async/zone.dart:1021:19)
#13 _runZoned (dart:async/zone.dart:1516:10)
#14 runZoned (dart:async/zone.dart:1463:12)
#15 AppContext.run (package:flutter_tools/src/base/context.dart:152:18)
<asynchronous suspension>
#16 FlutterCommand.run (package:flutter_tools/src/runner/flutter_command.dart:375:20)
#17 CommandRunner.runCommand (package:args/command_runner.dart:197:27)
<asynchronous suspension>
#18 FlutterCommandRunner.runCommand.<anonymous closure> (package:flutter_tools/src/runner/flutter_command_runner.dart:396:21)
<asynchronous suspension>
#19 AppContext.run.<anonymous closure> (package:flutter_tools/src/base/context.dart:153:29)
<asynchronous suspension>
#20 _rootRun (dart:async/zone.dart:1124:13)
#21 _CustomZone.run (dart:async/zone.dart:1021:19)
#22 _runZoned (dart:async/zone.dart:1516:10)
#23 runZoned (dart:async/zone.dart:1463:12)
#24 AppContext.run (package:flutter_tools/src/base/context.dart:152:18)
<asynchronous suspension>
#25 FlutterCommandRunner.runCommand (package:flutter_tools/src/runner/flutter_command_runner.dart:356:19)
<asynchronous suspension>
#26 CommandRunner.run.<anonymous closure> (package:args/command_runner.dart:112:25)
#27 new Future.sync (dart:async/future.dart:224:31)
#28 CommandRunner.run (package:args/command_runner.dart:112:14)
#29 FlutterCommandRunner.run (package:flutter_tools/src/runner/flutter_command_runner.dart:242:18)
#30 run.<anonymous closure>.<anonymous closure> (package:flutter_tools/runner.dart:62:22)
<asynchronous suspension>
#31 _rootRun (dart:async/zone.dart:1124:13)
#32 _CustomZone.run (dart:async/zone.dart:1021:19)
#33 _runZoned (dart:async/zone.dart:1516:10)
#34 runZoned (dart:async/zone.dart:1500:12)
#35 run.<anonymous closure> (package:flutter_tools/runner.dart:60:18)
<asynchronous suspension>
#36 AppContext.run.<anonymous closure> (package:flutter_tools/src/base/context.dart:153:29)
<asynchronous suspension>
#37 _rootRun (dart:async/zone.dart:1124:13)
#38 _CustomZone.run (dart:async/zone.dart:1021:19)
#39 _runZoned (dart:async/zone.dart:1516:10)
#40 runZoned (dart:async/zone.dart:1463:12)
#41 AppContext.run (package:flutter_tools/src/base/context.dart:152:18)
<asynchronous suspension>
#42 runInContext (package:flutter_tools/src/context_runner.dart:56:24)
<asynchronous suspension>
#43 run (package:flutter_tools/runner.dart:51:10)
#44 main (package:flutter_tools/executable.dart:62:9)
<asynchronous suspension>
#45 main (file:///Users/pranithrao/Downloads/flutter/packages/flutter_tools/bin/flutter_tools.dart:8:3)
#46 _startIsolate.<anonymous closure> (dart:isolate-patch/isolate_patch.dart:299:32)
#47 _RawReceivePortImpl._handleMessage (dart:isolate-patch/isolate_patch.dart:172:12)
答案 0 :(得分:0)
删除项目主路径中的android
文件夹,然后重新安装应用程序。
android
文件夹将再次创建。此解决方案解决了flutter项目中gradle
的大部分问题。