我如何修复这个Flutter错误,以便我可以在Android上运行应用程序?



嗨,我使用vscode与flutter扩展并创建了一个新项目,没有改变任何东西,但当我尝试在android上运行它时,我只是得到这个:

Launching libmain.dart on SDK Gphone x86 in debug mode...
libmain.dart:1
Warning: Mapping new ns http://schemas.android.com/repository/android/common/02 to old ns http://schemas.android.com/repository/android/common/01
Warning: Mapping new ns http://schemas.android.com/repository/android/generic/02 to old ns http://schemas.android.com/repository/android/generic/01
Warning: Mapping new ns http://schemas.android.com/sdk/android/repo/addon2/02 to old ns http://schemas.android.com/sdk/android/repo/addon2/01
Warning: Mapping new ns http://schemas.android.com/sdk/android/repo/repository2/02 to old ns http://schemas.android.com/sdk/android/repo/repository2/01
Warning: Mapping new ns http://schemas.android.com/sdk/android/repo/sys-img2/02 to old ns http://schemas.android.com/sdk/android/repo/sys-img2/01
FAILURE: Build failed with an exception.
* Where:
Script 'D:flutterflutterpackagesflutter_toolsgradleflutter.gradle' line: 1005
* What went wrong:
Execution failed for task ':app:compileFlutterBuildDebug'.
> Process 'command 'D:flutterflutterbinflutter.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 4m 1s
Exception: Gradle task assembleDebug failed with exit code 1
Exited (sigterm)

当我尝试在Web上运行它时,它工作得很好,但当我尝试在android模拟器或真正的android手机上运行它时,它产生与上面所示相同的错误。

我已经尝试过清理工作空间并更新到最新的和开发版本的flutter。

flutter doctor不会产生任何错误,并表示一切正常。

有人能帮忙吗?

编辑:fluttter run --verbose输出:

20:41:03.74 | LSH | D:programmingVScodeFlutterTestApptest_application_1> flutter run --verbose
[ +112 ms] executing: [D:flutterflutter/] git -c log.showSignature=false log -n 1 --pretty=f
[ +171 ms] Exit code 0 from: git -c log.showSignature=false log -n 1 --pretty=format:%H
[   +1 ms] 4b330ddbedab445481cc73d50a4695b9154b4e4f
[   +1 ms] executing: [D:flutterflutter/] git tag --points-at 4b330ddbedab445481cc73d50a4695
[ +133 ms] Exit code 0 from: git tag --points-at 4b330ddbedab445481cc73d50a4695b9154b4e4f
[        ] 2.6.0-11.0.pre
[  +16 ms] executing: [D:flutterflutter/] git rev-parse --abbrev-ref --symbolic @{u}
[ +101 ms] Exit code 0 from: git rev-parse --abbrev-ref --symbolic @{u}
[        ] origin/dev
[        ] executing: [D:flutterflutter/] git ls-remote --get-url origin
[ +102 ms] Exit code 0 from: git ls-remote --get-url origin
[        ] https://github.com/flutter/flutter.git
[ +269 ms] executing: [D:flutterflutter/] git rev-parse --abbrev-ref HEAD
[ +104 ms] Exit code 0 from: git rev-parse --abbrev-ref HEAD
[        ] dev
[ +130 ms] Artifact Instance of 'AndroidGenSnapshotArtifacts' is not required, skipping update
[        ] Artifact Instance of 'AndroidInternalBuildArtifacts' is not required, skipping upda
[        ] Artifact Instance of 'IOSEngineArtifacts' is not required, skipping update.
[        ] Artifact Instance of 'FlutterWebSdk' is not required, skipping update.
[   +8 ms] Artifact Instance of 'WindowsEngineArtifacts' is not required, skipping update.
[        ] Artifact Instance of 'WindowsUwpEngineArtifacts' is not required, skipping update.
[   +1 ms] Artifact Instance of 'MacOSEngineArtifacts' is not required, skipping update.
[        ] Artifact Instance of 'LinuxEngineArtifacts' is not required, skipping update.
is not required, skipping update.                    acts' is not required, skipping update.
[  +16 ms] Artifact Instance of 'WindowsUwpEngineArtiacts' is not required, skipping update.facts' is not required, skipping update.             facts' is not required, skipping update.
[        ] Artifact Instance of 'MacOSEngineArtifactsmbols' is not required, skipping update.' is not required, skipping update.                  idsdkplatform-toolsadb.exe devices -l
[        ] Artifact Instance of 'LinuxEngineArtifacts' is not required, skipping update.                  duct:r8qxxx model:SM_G781B device:r8q tra
[        ] Artifact Instance of 'LinuxFuchsiaSDKArtifform-toolsadb.exe -s RFCR40FYKDA shell gacts' is not required, skipping update.              Artifacts' is not required, skipping upda
[        ] Artifact Instance of 'MacOSFuchsiaSDKArtifis not required, skipping update.acts' is not required, skipping update.              facts' is not required, skipping update.
[        ] Artifact Instance of 'FlutterRunnerSDKArti' is not required, skipping update.facts' is not required, skipping update.             ' is not required, skipping update.
[        ] Artifact Instance of 'FlutterRunnerDebugSyacts' is not required, skipping update.mbols' is not required, skipping update.             acts' is not required, skipping update.
[ +164 ms] Skipping pub get: version match.          facts' is not required, skipping update.
[ +224 ms] Generating D:programmingVScodeFlutterTmbols' is not required, skipping update.estApptest_application_1androidappsrcmainjavaioflutterpluginsGeneratedPluginRegistrant.java     estApptest_application_1androidappsrc
[ +240 ms] ro.hardware = qcom
[ +112 ms] Initializing file store
[  +38 ms] Skipping target: gen_localizations
[  +16 ms] Skipping target:
gen_dart_plugin_registrant
[   +8 ms] Skipping target: _composite
[   +5 ms] complete
[  +17 ms] Launching libmain.dart on SM G781B in
debug mode...
[  +17 ms]
D:flutterflutterbincachedart-sdkbindart.exe   
--disable-dart-dev
D:flutterflutterbincacheartifactsenginewindows-x64frontend_server.dart.snapshot --sdk-root        
D:flutterflutterbincacheartifactsenginecommonflutter_patched_sdk/ --incremental --target=flutter  
--debugger-module-names
--experimental-emit-debug-metadata
-DFLUTTER_WEB_AUTO_DETECT=true --output-dill
C:UsersPCAppDataLocalTempflutter_tools.3b35b6d3flutter_tool.4187a6beapp.dill --packages
D:programmingVScodeFlutterTestApptest_application_1.dart_toolpackage_config.json       
-Ddart.vm.profile=false -Ddart.vm.product=false
--enable-asserts --track-widget-creation
--filesystem-scheme org-dartlang-root
--initialize-from-dill
buildc075001b96339384a97db4862b8ab8db.cache.dill.track.dill
--enable-experiment=alternative-invalidation-strategy[  +37 ms] executing:
C:UsersPCAppDataLocalAndroidsdkplatform-toolsadb.exe -s RFCR40FYKDA shell -x logcat -v time -t 1
[  +35 ms] <- compile
package:test_application_1/main.dart
[ +611 ms] --------- beginning of system
10-08 20:42:31.670 E/Watchdog( 1139): !@Sync: 5393 heap: 120 / 129
[2021-10-08 20:42:31.669] sdogWay: softdog FD: 785
[  +26 ms] executing: C:UsersPCAppDataLocalAndroidsdkplatform-toolsadb.exe version
[  +73 ms] Android Debug Bridge version 1.0.41
Version 31.0.3-7562133
Installed as C:UsersPCAppDataLocalAndroidsdkplatform-toolsadb.exe
[   +3 ms] executing: C:UsersPCAppDataLocalAndroidsdkplatform-toolsadb.exe
start-server
[  +56 ms] Building APK
[  +28 ms] Running Gradle task 'assembleDebug'...
[   +7 ms] Using gradle from
D:programmingVScodeFlutterTestApptest_application_1androidgradlew.bat.
[ +102 ms] executing: C:Program FilesAndroidAndroid Studio1jrebinjava -version
[ +986 ms] Exit code 0 from: C:Program FilesAndroidAndroid Studio1jrebinjava -version
[   +1 ms] openjdk version "11.0.10" 2021-01-19
OpenJDK Runtime Environment (build 11.0.10+0-b96-7249189)
OpenJDK 64-Bit Server VM (build 11.0.10+0-b96-7249189, mixed mode)
[   +3 ms] executing: [D:programmingVScodeFlutterTestApptest_application_1android/]     
D:programmingVScodeFlutterTestApptest_application_1androidgradlew.bat -Pverbose=true   
-Ptarget-platform=android-arm64
-Ptarget=D:programmingVScodeFlutterTestApptest_application_1libmain.dart
-Pdart-defines=RkxVVFRFUl9XRUJfQVVUT19ERVRFQ1Q9dHJ1ZQ== -Pdart-obfuscation=false
-Ptrack-widget-creation=true -Ptree-shake-icons=false -Pfilesystem-scheme=org-dartlang-root   
assembleDebug
[+11333 ms] Warning: Mapping new ns http://schemas.android.com/repository/android/common/02 toold ns http://schemas.android.com/repository/android/common/01
[ +250 ms] Warning: Mapping new ns http://schemas.android.com/repository/android/generic/02 toold ns http://schemas.android.com/repository/android/generic/01
[  +35 ms] Warning: Mapping new ns http://schemas.android.com/sdk/android/repo/addon2/02 to
old ns http://schemas.android.com/sdk/android/repo/addon2/01
[   +7 ms] Warning: Mapping new ns http://schemas.android.com/sdk/android/repo/repository2/02
to old ns http://schemas.android.com/sdk/android/repo/repository2/01
[  +13 ms] Warning: Mapping new ns http://schemas.android.com/sdk/android/repo/sys-img2/02 to
old ns http://schemas.android.com/sdk/android/repo/sys-img2/01
[+2142 ms] > Task :app:compileFlutterBuildDebug
[  +20 ms] [ +146 ms] executing: [D:flutterflutter/] git -c log.showSignature=false log -n 1--pretty=format:%H
[ +175 ms] [ +198 ms] Exit code 0 from: git -c log.showSignature=false log -n 1
--pretty=format:%H
[   +3 ms] [        ] 4b330ddbedab445481cc73d50a4695b9154b4e4f
[        ] [        ] executing: [D:flutterflutter/] git tag --points-at
4b330ddbedab445481cc73d50a4695b9154b4e4f
[+1196 ms] [+1242 ms] Exit code 0 from: git tag --points-at
4b330ddbedab445481cc73d50a4695b9154b4e4f
[   +2 ms] [        ] 2.6.0-11.0.pre
[        ] [  +16 ms] executing: [D:flutterflutter/] git rev-parse --abbrev-ref --symbolic  
@{u}
[ +497 ms] [ +415 ms] Exit code 0 from: git rev-parse --abbrev-ref --symbolic @{u}
[   +2 ms] [        ] origin/dev
[        ] [        ] executing: [D:flutterflutter/] git ls-remote --get-url origin
[ +196 ms] [ +274 ms] Exit code 0 from: git ls-remote --get-url origin
[   +2 ms] [        ] https://github.com/flutter/flutter.git
[  +96 ms] [  +90 ms] executing: [D:flutterflutter/] git rev-parse --abbrev-ref HEAD
[ +101 ms] [ +109 ms] Exit code 0 from: git rev-parse --abbrev-ref HEAD
[   +1 ms] [        ] dev
[ +198 ms] [ +134 ms] Artifact Instance of 'AndroidGenSnapshotArtifacts' is not required,
skipping update.
[   +3 ms] [        ] Artifact Instance of 'AndroidInternalBuildArtifacts' is not required,
skipping update.
[   +1 ms] [        ] Artifact Instance of 'IOSEngineArtifacts' is not required, skipping     
update.
[   +2 ms] [        ] Artifact Instance of 'FlutterWebSdk' is not required, skipping update.  
[   +1 ms] [   +5 ms] Artifact Instance of 'WindowsEngineArtifacts' is not required, skipping 
update.
[   +1 ms] [        ] Artifact Instance of 'WindowsUwpEngineArtifacts' is not required,       
skipping update.
[   +2 ms] [        ] Artifact Instance of 'MacOSEngineArtifacts' is not required, skipping
update.
[   +1 ms] [        ] Artifact Instance of 'LinuxEngineArtifacts' is not required, skipping   
update.
[   +4 ms] [        ] Artifact Instance of 'LinuxFuchsiaSDKArtifacts' is not required,        
skipping update.
[   +3 ms] [        ] Artifact Instance of 'MacOSFuchsiaSDKArtifacts' is not required,
skipping update.
[   +1 ms] [        ] Artifact Instance of 'FlutterRunnerSDKArtifacts' is not required,       
skipping update.
[   +1 ms] [        ] Artifact Instance of 'FlutterRunnerDebugSymbols' is not required,       
skipping update.
[ +175 ms] [ +183 ms] Artifact Instance of 'MaterialFonts' is not required, skipping update.
[   +2 ms] [        ] Artifact Instance of 'GradleWrapper' is not required, skipping update.
[   +2 ms] [   +7 ms] Artifact Instance of 'AndroidInternalBuildArtifacts' is not required,   
skipping update.
[   +1 ms] [        ] Artifact Instance of 'IOSEngineArtifacts' is not required, skipping     
update.
[   +1 ms] [        ] Artifact Instance of 'FlutterWebSdk' is not required, skipping update.  
[   +1 ms] [        ] Artifact Instance of 'FlutterSdk' is not required, skipping update.
[   +3 ms] [        ] Artifact Instance of 'WindowsEngineArtifacts' is not required, skipping
update.
[  +14 ms] [        ] Artifact Instance of 'WindowsUwpEngineArtifacts' is not required,
skipping update.
[   +4 ms] [        ] Artifact Instance of 'MacOSEngineArtifacts' is not required, skipping   
update.
[   +4 ms] [        ] Artifact Instance of 'LinuxEngineArtifacts' is not required, skipping   
update.
[   +1 ms] [        ] Artifact Instance of 'LinuxFuchsiaSDKArtifacts' is not required,
skipping update.
[   +4 ms] [        ] Artifact Instance of 'MacOSFuchsiaSDKArtifacts' is not required,        
skipping update.
[   +4 ms] [        ] Artifact Instance of 'FlutterRunnerSDKArtifacts' is not required,
skipping update.
[   +9 ms] [        ] Artifact Instance of 'FlutterRunnerDebugSymbols' is not required,
skipping update.
[   +4 ms] [        ] Artifact Instance of 'IosUsbArtifacts' is not required, skipping update.[   +6 ms] [        ] Artifact Instance of 'IosUsbArtifacts' is not required, skipping update.[   +1 ms] [        ] Artifact Instance of 'IosUsbArtifacts' is not required, skipping update.[   +2 ms] [        ] Artifact Instance of 'IosUsbArtifacts' is not required, skipping update.[   +2 ms] [        ] Artifact Instance of 'IosUsbArtifacts' is not required, skipping update.[   +2 ms] [        ] Artifact Instance of 'FontSubsetArtifacts' is not required, skipping    
update.
[   +1 ms] [        ] Artifact Instance of 'PubDependencies' is not required, skipping update.[   +5 ms] [  +53 ms] Initializing file store
[   +1 ms] [  +26 ms] Done initializing file store
[  +11 ms] [  +97 ms] Skipping target: gen_localizations
[ +100 ms] [  +22 ms] Skipping target: gen_dart_plugin_registrant
[ +500 ms] [ +563 ms] Skipping target: kernel_snapshot
[ +299 ms] [ +313 ms] Skipping target: debug_android_application
[   +2 ms] [        ] Persisting file store
[  +97 ms] [  +11 ms] Done persisting file store
[   +1 ms] [   +7 ms] build succeeded.
[   +5 ms] [  +29 ms] "flutter assemble" took 1’339ms.
[ +193 ms] [ +218 ms] ensureAnalyticsSent: 210ms
[   +1 ms] [   +1 ms] Running shutdown hooks
[        ] [        ] Shutdown hooks complete
[   +1 ms] [        ] exiting with code 0
[  +95 ms] > Task :app:compileFlutterBuildDebug FAILED
[   +4 ms] FAILURE: Build failed with an exception.
[   +1 ms] * Where:
[   +1 ms] Script 'D:flutterflutterpackagesflutter_toolsgradleflutter.gradle' line: 1005[   +1 ms] * What went wrong:
[   +9 ms] Execution failed for task ':app:compileFlutterBuildDebug'.
[   +4 ms] > Process 'command 'D:flutterflutterbinflutter.bat'' finished with non-zero    
exit value 1
[   +2 ms] * 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.
[   +1 ms] * Get more help at https://help.gradle.org
[        ] BUILD FAILED in 17s
[   +1 ms] Deprecated Gradle features were used in this build, making it incompatible with    
Gradle 7.0.
[   +1 ms] 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   
[   +4 ms] 1 actionable task: 1 executed
[ +507 ms] Running Gradle task 'assembleDebug'... (completed in 19.5s)
[   +6 ms] Exception: Gradle task assembleDebug failed with exit code 1
[   +4 ms] "flutter run" took 22’000ms.
[  +11 ms] 
#0      throwToolExit (package:flutter_tools/src/base/common.dart:10:3)
#1      RunCommand.runCommand (package:flutter_tools/src/commands/run.dart:669:9)  
<asynchronous suspension>
#2      FlutterCommand.run.<anonymous closure>
(package:flutter_tools/src/runner/flutter_command.dart:1125:27)
<asynchronous suspension>
#3      AppContext.run.<anonymous closure>
(package:flutter_tools/src/base/context.dart:150:19)
<asynchronous suspension>
#4      CommandRunner.runCommand (package:args/command_runner.dart:209:13)
<asynchronous suspension>
#5      FlutterCommandRunner.runCommand.<anonymous closure>
(package:flutter_tools/src/runner/flutter_command_runner.dart:288:9)
<asynchronous suspension>
#6      AppContext.run.<anonymous closure>
(package:flutter_tools/src/base/context.dart:150:19)
<asynchronous suspension>
#7      FlutterCommandRunner.runCommand
(package:flutter_tools/src/runner/flutter_command_runner.dart:236:5)
<asynchronous suspension>
#8      run.<anonymous closure>.<anonymous closure>
(package:flutter_tools/runner.dart:62:9)
<asynchronous suspension>
#9      AppContext.run.<anonymous closure>
(package:flutter_tools/src/base/context.dart:150:19)
<asynchronous suspension>
#10     main (package:flutter_tools/executable.dart:92:3)
<asynchronous suspension>

[  +82 ms] ensureAnalyticsSent: 73ms
[   +5 ms] Running shutdown hooks
[   +1 ms] Shutdown hooks complete
[   +1 ms] exiting with code 1

Try

flutter clean 

,

flutter pub get

方法2:

升级gradle版本到7.0.2 or higher

手动方式,

更改gradle-wrapper.properties中的distributionUrl

distributionUrl=https://services.gradle.org/distributions/gradle-7.0.2-bin.zip

更改build.gradle, gradle版本在dependencies

classpath 'com.android.tools.build:gradle:7.0.2'

相关内容

  • 没有找到相关文章

最新更新