你如何解决颤振构建错误?

Posted

技术标签:

【中文标题】你如何解决颤振构建错误?【英文标题】:how do you resolve flutter build errors? 【发布时间】:2021-05-12 21:14:35 【问题描述】:

我正在尝试为此应用程序构建 APK 文件,但我遇到了一些我不明白的错误。我已经搜索了这个平台和 Github,但没有任何帮助。 我该如何解决这个问题?

[+391809 ms] FAILURE: Build failed with an exception.
[   +8 ms] * What went wrong:
[   +4 ms] A problem occurred configuring project ':sqflite'.
[ +679 ms] > Could not resolve all artifacts for configuration ':sqflite:classpath'.
[  +76 ms]    > Could not download tensorflow-lite-metadata.jar (org.tensorflow:tensorflow-lite-metadata:0.1.0-rc1)
[   +2 ms]       > Could not get resource
'https://jcenter.bintray.com/org/tensorflow/tensorflow-lite-metadata/0.1.0-rc1/tensorflow-lite-metadata-0.1.0-rc1.jar'.
[   +8 ms]          > Could not GET
'https://jcenter.bintray.com/org/tensorflow/tensorflow-lite-metadata/0.1.0-rc1/tensorflow-lite-metadata-0.1.0-rc1.jar'.
[   +5 ms]             > Remote host closed connection during handshake
[   +3 ms]    > Could not download flatbuffers-java.jar (com.google.flatbuffers:flatbuffers-java:1.12.0)
[   +8 ms]       > Could not get resource
'https://jcenter.bintray.com/com/google/flatbuffers/flatbuffers-java/1.12.0/flatbuffers-java-1.12.0.jar'.
[   +5 ms]          > Could not GET
'https://jcenter.bintray.com/com/google/flatbuffers/flatbuffers-java/1.12.0/flatbuffers-java-1.12.0.jar'.
[  +37 ms]             > Remote host closed connection during handshake
[   +3 ms] > Could not get unknown property 'android' for project ':sqflite' of type org.gradle.api.Project.
[   +2 ms] * Try:
[   +3 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.
[   +3 ms] * Get more help at https://help.gradle.org
[   +4 ms] BUILD FAILED in 7m 21s
[+4489 ms] Running Gradle task 'assembleRelease'... (completed in 463.3s, longer than expected)
[  +93 ms] "flutter apk" took 495,189ms.
[  +62 ms] Gradle task assembleRelease failed with exit code 1
[ +160 ms] 
                   #0      throwToolExit (package:flutter_tools/src/base/common.dart:14:3)
                   #1      buildGradleApp (package:flutter_tools/src/android/gradle.dart:416:7)
                   #2      _rootRunUnary (dart:async/zone.dart:1198:47)
                   #3      _CustomZone.runUnary (dart:async/zone.dart:1100:19)
                   #4      _FutureListener.handleValue (dart:async/future_impl.dart:143:18)
                   #5      Future._propagateToListeners.handleValueCallback (dart:async/future_impl.dart:696:45)
                   #6      Future._propagateToListeners (dart:async/future_impl.dart:725:32)
                   #7      Future._completeWithValue (dart:async/future_impl.dart:529:5)
                   #8      _AsyncAwaitCompleter.complete (dart:async-patch/async_patch.dart:40:15)
                   #9      _completeOnAsyncReturn (dart:async-patch/async_patch.dart:311:13)
                   #10     _DefaultProcessUtils.stream (package:flutter_tools/src/base/process.dart)
                   #11     _rootRunUnary (dart:async/zone.dart:1198:47)
                   #12     _CustomZone.runUnary (dart:async/zone.dart:1100:19)
                   #13     _FutureListener.handleValue (dart:async/future_impl.dart:143:18)
                   #14     Future._propagateToListeners.handleValueCallback (dart:async/future_impl.dart:696:45)
                   #15     Future._propagateToListeners (dart:async/future_impl.dart:725:32)
                   #16     Future._completeWithValue (dart:async/future_impl.dart:529:5)
                   #17     Future._asyncCompleteWithValue.<anonymous closure> (dart:async/future_impl.dart:567:7)
                   #18     _rootRun (dart:async/zone.dart:1190:13)
                   #19     _CustomZone.run (dart:async/zone.dart:1093:19)
                   #20     _CustomZone.runGuarded (dart:async/zone.dart:997:7)
                   #21     _CustomZone.bindCallbackGuarded.<anonymous closure> (dart:async/zone.dart:1037:23)
                   #22     _microtaskLoop (dart:async/schedule_microtask.dart:41:21)
                   #23     _startMicrotaskLoop (dart:async/schedule_microtask.dart:50:5)
                   #24     _runPendingImmediateCallback (dart:isolate-patch/isolate_patch.dart:118:13)
                   #25     _RawReceivePortImpl._handleMessage (dart:isolate-patch/isolate_patch.dart:169:5) 

我认为导致此错误的插件可能是:sqflite: ^1.3.2+1

更新:我使用了flutter clean,它解决了上述问题。

然而,另一个出现了:

Execution failed for task ':app:validateSigningRelease'.
[  +64 ms] > Keystore file 'C:\Users\ZZZ\FlutterProjects\trivia\android\app\C:UsersZZZjkskey.jks' not found for signing config
'release'.

这里出了什么问题?为什么路径C:UsersZZZjkskey.jks' 中缺少反斜杠?

【问题讨论】:

您是否尝试过在终端 flutter cleanflutter build apk 内进行清理和构建。 是的,我在运行 flutter build apk@reas 之前这样做了 【参考方案1】:

尝试使用以下:

implementation 'org.tensorflow:tensorflow-lite-metadata:0.1.0-rc2'

【讨论】:

【参考方案2】:

一周前我遇到了同样的问题,我执行了以下步骤来从这个错误中恢复。

在文件夹android &gt; gradle &gt; wrapper &gt; gradle-wrapper.properties中将distributionUrl改为https\://services.gradle.org/distributions/gradle-5.6.2-all.zip

在此之后运行flutter pub cache repair。 一旦完成,没有任何错误。从模拟器/测试手机卸载后触发flutter clean命令并重新运行应用程序,错误应该已经消失了。

【讨论】:

【参考方案3】:

我在key.properties 文件中犯了一个错误。 在文件中,我将storeFile 变量从存储key.jks 的路径更改为key.jks,构建成功。

【讨论】:

以上是关于你如何解决颤振构建错误?的主要内容,如果未能解决你的问题,请参考以下文章

为啥颤振向我显示此错误,我该如何解决?

一个奇怪的颤振错误,我不知道如何解决

如何解决颤振上的 pod install 错误?

颤振医生 --android-licenses 错误,如何解决这个问题?

如何解决颤振包 google_mobile_ads 中的此错误

如何在执行 POST 请求时解决颤振 CERTIFICATE_VERIFY_FAILED 错误?