构建失败并出现异常。颤动的Gradle问题
Posted
技术标签:
【中文标题】构建失败并出现异常。颤动的Gradle问题【英文标题】:Build failed with an exception. Gradle problem with flutter 【发布时间】:2020-09-06 08:40:37 【问题描述】:我正在尝试为我的应用构建 gradle,但构建失败
我尝试更改 gradle 版本号和 gradle 插件版本号,但每次我得到愚蠢的错误,我不知道为什么!我根据这个doc尝试并改变了
gradle 5.6.4 >>> gradle 插件版本 3.6.3
gradle 5.6.4 >>> gradle 插件版本 3.6.0
gradle 5.6.4 >>> gradle 插件版本 3.4.0
gradle 5.6.2 >>> gradle 插件版本 3.6.0
gradle 5.6.2 >>> gradle 插件版本 3.5.0
而且列表还在继续,但每次显示时我都会遇到相同的错误:
* What went wrong:
A problem occurred evaluating project ':app'.
> com/google/common/util/concurrent/SettableFuture
我试图根据这个 question 更改基础 帮助导致我在过去 3 天里因为这个错误而遇到麻烦,而且我是新手。 目前的数字是:
distributionUrl=https\://services.gradle.org/distributions/gradle-5.6.4-all.zip
classpath 'com.android.tools.build:gradle:3.6.3'
谢谢
这是flutter run -v的结果
[ +31 ms] executing: [C:\src\flutter/] git -c log.showSignature=false log -n 1 --pretty=format:%H
[ +79 ms] Exit code 0 from: git -c log.showSignature=false log -n 1 --pretty=format:%H
[ +1 ms] f7a6a7906be96d2288f5d63a5a54c515a6e987fe
[ +1 ms] executing: [C:\src\flutter/] git tag --contains HEAD
[ +410 ms] Exit code 0 from: git tag --contains HEAD
[ +2 ms] 1.17.1
[ +13 ms] executing: [C:\src\flutter/] git rev-parse --abbrev-ref --symbolic @u
[ +34 ms] Exit code 0 from: git rev-parse --abbrev-ref --symbolic @u
[ ] origin/stable
[ ] executing: [C:\src\flutter/] git ls-remote --get-url origin
[ +28 ms] Exit code 0 from: git ls-remote --get-url origin
[ ] https://github.com/flutter/flutter.git
[ +180 ms] executing: [C:\src\flutter/] git rev-parse --abbrev-ref HEAD
[ +98 ms] Exit code 0 from: git rev-parse --abbrev-ref HEAD
[ ] stable
[ +77 ms] Artifact Instance of 'AndroidMavenArtifacts' is not required, skipping update.
[ +1 ms] Artifact Instance of 'AndroidGenSnapshotArtifacts' is not required, skipping update.
[ +1 ms] Artifact Instance of 'AndroidInternalBuildArtifacts' is not required, skipping update.
[ ] Artifact Instance of 'iosEngineArtifacts' is not required, skipping update.
[ ] Artifact Instance of 'FlutterWebSdk' is not required, skipping update.
[ +6 ms] Artifact Instance of 'WindowsEngineArtifacts' is not required, skipping update.
[ ] Artifact Instance of 'MacOSEngineArtifacts' is not required, skipping update.
[ ] Artifact Instance of 'LinuxEngineArtifacts' is not required, skipping update.
[ ] Artifact Instance of 'LinuxFuchsiaSDKArtifacts' is not required, skipping update.
[ ] Artifact Instance of 'MacOSFuchsiaSDKArtifacts' is not required, skipping update.
[ ] Artifact Instance of 'FlutterRunnerSDKArtifacts' is not required, skipping update.
[ ] Artifact Instance of 'FlutterRunnerDebugSymbols' is not required, skipping update.
[ +63 ms] executing: C:\android\src\platform-tools\adb.exe devices -l
[ +69 ms] List of devices attached
127.0.0.1:62001 device product:dream2ltexx model:SM_G930K device:shamu transport_id:1
[ +16 ms] C:\android\src\platform-tools\adb.exe -s 127.0.0.1:62001 shell getprop
[ +71 ms] Artifact Instance of 'AndroidMavenArtifacts' is not required, skipping update.
[ +10 ms] Artifact Instance of 'AndroidInternalBuildArtifacts' is not required, skipping update.
[ +1 ms] Artifact Instance of 'IOSEngineArtifacts' is not required, skipping update.
[ ] Artifact Instance of 'FlutterWebSdk' is not required, skipping update.
[ +3 ms] Artifact Instance of 'WindowsEngineArtifacts' is not required, skipping update.
[ ] Artifact Instance of 'MacOSEngineArtifacts' is not required, skipping update.
[ ] Artifact Instance of 'LinuxEngineArtifacts' is not required, skipping update.
[ ] Artifact Instance of 'LinuxFuchsiaSDKArtifacts' is not required, skipping update.
[ ] Artifact Instance of 'MacOSFuchsiaSDKArtifacts' is not required, skipping update.
[ ] Artifact Instance of 'FlutterRunnerSDKArtifacts' is not required, skipping update.
[ ] Artifact Instance of 'FlutterRunnerDebugSymbols' is not required, skipping update.
[ +424 ms] Generating
C:\Users\Milad\AndroidStudioProjects\flutter_app123\android\app\src\main\java\io\flutter\plugins\GeneratedPluginRegistrant.java
[ +81 ms] ro.hardware = samsungexynos9810
[ +100 ms] Launching lib\main.dart on SM G930K in debug mode...
[ +16 ms] C:\src\flutter\bin\cache\dart-sdk\bin\dart.exe
C:\src\flutter\bin\cache\artifacts\engine\windows-x64\frontend_server.dart.snapshot --sdk-root
C:\src\flutter\bin\cache\artifacts\engine\common\flutter_patched_sdk/ --incremental --target=flutter --debugger-module-names
-Ddart.developer.causal_async_stacks=true --output-dill
C:\Users\Milad\AppData\Local\Temp\flutter_tool.dea96117-9a58-11ea-b26c-003018a2b692\app.dill --packages
C:\Users\Milad\AndroidStudioProjects\flutter_app123\.packages -Ddart.vm.profile=false -Ddart.vm.product=false
--bytecode-options=source-positions,local-var-info,debugger-stops,instance-field-initializers,keep-unreachable-code,avoid-closure-
call-instructions --enable-asserts --track-widget-creation --filesystem-scheme org-dartlang-root --initialize-from-dill
build\cache.dill
[ +36 ms] executing: C:\android\src\platform-tools\adb.exe -s 127.0.0.1:62001 shell -x logcat -v time -t 1
[ +80 ms] Exit code 0 from: C:\android\src\platform-tools\adb.exe -s 127.0.0.1:62001 shell -x logcat -v time -t 1
[ +1 ms] --------- beginning of main
05-20 09:45:19.493 I/LockboxService( 2694): Completed task: true
[ +19 ms] <- compile package:flutterapp123/main.dart
[ +11 ms] executing: C:\android\src\platform-tools\adb.exe version
[ +43 ms] Android Debug Bridge version 1.0.41
Version 30.0.1-6435776
Installed as C:\android\src\platform-tools\adb.exe
[ +11 ms] executing: C:\android\src\platform-tools\adb.exe start-server
[ +39 ms] Building APK
[ +34 ms] Running Gradle task 'assembleDebug'...
[ +5 ms] gradle.properties already sets `android.enableR8`
[ +33 ms] Using gradle from C:\Users\Milad\AndroidStudioProjects\flutter_app123\android\gradlew.bat.
[ +2 ms] C:\Users\Milad\AndroidStudioProjects\flutter_app123\android\gradlew.bat mode: 33279 rwxrwxrwx.
[ +47 ms] executing: C:\Program Files\Android\Android Studio\jre\bin\java -version
[ +827 ms] Exit code 0 from: C:\Program Files\Android\Android Studio\jre\bin\java -version
[ +1 ms] openjdk version "1.8.0_212-release"
OpenJDK Runtime Environment (build 1.8.0_212-release-1586-b04)
OpenJDK 64-Bit Server VM (build 25.212-b04, mixed mode)
[ +6 ms] executing: [C:\Users\Milad\AndroidStudioProjects\flutter_app123\android/]
C:\Users\Milad\AndroidStudioProjects\flutter_app123\android\gradlew.bat -Pverbose=true -Ptarget-platform=android-x86
-Ptarget=C:\Users\Milad\AndroidStudioProjects\flutter_app123\lib\main.dart -Ptrack-widget-creation=true
-Pfilesystem-scheme=org-dartlang-root assembleDebug
[+1433 ms] Welcome to Gradle 5.6.4!
[ +2 ms] Here are the highlights of this release:
[ ] - Incremental Groovy compilation
[ ] - Groovy compile avoidance
[ ] - Test fixtures for Java projects
[ +1 ms] - Manage plugin versions via settings script
[ +1 ms] For more details see https://docs.gradle.org/5.6.4/release-notes.html
[+2954 ms] FAILURE: Build failed with an exception.
[ +97 ms] * Where:
[ ] Build file 'C:\Users\Milad\AndroidStudioProjects\flutter_app123\android\app\build.gradle' line: 24
[ +1 ms] * What went wrong:
[ +1 ms] A problem occurred evaluating project ':app'.
[ +2 ms] > com/google/common/util/concurrent/SettableFuture
[ +16 ms] * Try:
[ +1 ms] 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.
[ +2 ms] * Get more help at https://help.gradle.org
[ +1 ms] BUILD FAILED in 3s
[ +949 ms] Running Gradle task 'assembleDebug'... (completed in 6.4s)
[+8351 ms] Exception: Gradle task assembleDebug failed with exit code 1
[ +5 ms] "flutter run" took 16,098ms.
#0 throwToolExit (package:flutter_tools/src/base/common.dart:14:3)
#1 RunCommand.runCommand (package:flutter_tools/src/commands/run.dart:569:7)
<asynchronous suspension>
#2 FlutterCommand.verifyThenRunCommand (package:flutter_tools/src/runner/flutter_command.dart:723:18)
#3 _rootRunUnary (dart:async/zone.dart:1192:38)
#4 _CustomZone.runUnary (dart:async/zone.dart:1085:19)
#5 _FutureListener.handleValue (dart:async/future_impl.dart:141:18)
#6 Future._propagateToListeners.handleValueCallback (dart:async/future_impl.dart:682:45)
#7 Future._propagateToListeners (dart:async/future_impl.dart:711:32)
#8 Future._completeWithValue (dart:async/future_impl.dart:526:5)
#9 _AsyncAwaitCompleter.complete (dart:async-patch/async_patch.dart:36:15)
#10 _completeOnAsyncReturn (dart:async-patch/async_patch.dart:298:13)
#11 RunCommand.usageValues (package:flutter_tools/src/commands/run.dart)
#12 _rootRunUnary (dart:async/zone.dart:1192:38)
#13 _CustomZone.runUnary (dart:async/zone.dart:1085:19)
#14 _FutureListener.handleValue (dart:async/future_impl.dart:141:18)
#15 Future._propagateToListeners.handleValueCallback (dart:async/future_impl.dart:682:45)
#16 Future._propagateToListeners (dart:async/future_impl.dart:711:32)
#17 Future._completeWithValue (dart:async/future_impl.dart:526:5)
#18 _AsyncAwaitCompleter.complete (dart:async-patch/async_patch.dart:36:15)
#19 _completeOnAsyncReturn (dart:async-patch/async_patch.dart:298:13)
#20 AndroidDevice.isLocalEmulator (package:flutter_tools/src/android/android_device.dart)
#21 _rootRunUnary (dart:async/zone.dart:1192:38)
#22 _CustomZone.runUnary (dart:async/zone.dart:1085:19)
#23 _FutureListener.handleValue (dart:async/future_impl.dart:141:18)
#24 Future._propagateToListeners.handleValueCallback (dart:async/future_impl.dart:682:45)
#25 Future._propagateToListeners (dart:async/future_impl.dart:711:32)
#26 Future._completeWithValue (dart:async/future_impl.dart:526:5)
#27 Future._asyncComplete.<anonymous closure> (dart:async/future_impl.dart:556:7)
#28 _rootRun (dart:async/zone.dart:1184:13)
#29 _CustomZone.run (dart:async/zone.dart:1077:19)
#30 _CustomZone.runGuarded (dart:async/zone.dart:979:7)
#31 _CustomZone.bindCallbackGuarded.<anonymous closure> (dart:async/zone.dart:1019:23)
#32 _microtaskLoop (dart:async/schedule_microtask.dart:43:21)
#33 _startMicrotaskLoop (dart:async/schedule_microtask.dart:52:5)
#34 _runPendingImmediateCallback (dart:isolate-patch/isolate_patch.dart:118:13)
#35 _RawReceivePortImpl._handleMessage (dart:isolate-patch/isolate_patch.dart:169:5)
【问题讨论】:
使用 'flutter run -v' 运行并发布堆栈跟踪 【参考方案1】:我清除了C:\Users\your username\.gradle\caches
中的缓存,构建成功。
【讨论】:
以上是关于构建失败并出现异常。颤动的Gradle问题的主要内容,如果未能解决你的问题,请参考以下文章