【问题标题】:Flutter shared_preferences Build failed with an exceptionFlutter shared_preferences Build失败并出现异常
【发布时间】:2020-06-29 13:31:25
【问题描述】:

我在使用shared preferences 并运行应用程序时遇到了一个非常奇怪的问题,我收到以下错误:

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':shared_preferences:extractDebugAnnotations'.
> Could not resolve all files for configuration ':shared_preferences:lintClassPath'.
   > Could not find kotlin-compiler.jar (com.android.tools.external.com-intellij:kotlin-compiler:26.5.0).
     Searched in the following locations:
         https://dl.google.com/dl/android/maven2/com/android/tools/external/com-intellij/kotlin-compiler/26.5.0/kotlin-compiler-26.5.0.jar

* 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 5s
Finished with error: Gradle task assembleDebug failed with exit code 1

我尝试了以下方法:

  1. 将 Flutter SDK/kotlin 更新到最新版本
  2. 命令:Flutter Doctor(查看是否有错误但一切正常)
  3. 更改 IDE(Visual Code 和 Intellij)
    • 无需修改代码即可创建新的flutter项目..项目运行正常

    • 我在 pubspec.yaml 中添加了http 包并点击了包获取,同样没有修改代码.. 项目运行没有问题

    • 然后我添加了shared preferencespubspec.yaml 并点击package get... 然后点击run 出现错误。

    • 我通过获取不同版本的shared preferences 重复了上一步,并且每次都遇到相同的错误。

    • 我尝试了stackoverflow上提供的所有解决方案,都没有用。

有什么帮助吗?

【问题讨论】:

  • 您可以尝试从终端运行“flutter clean”并重试吗?
  • @Arno 很遗憾没有工作...同样的错误

标签: android flutter kotlin package sharedpreferences


【解决方案1】:

就我而言,我只是运行:

flutter pub cache repair

之后,错误不再发生。希望这会有所帮助

【讨论】:

    猜你喜欢
    • 2018-11-17
    • 2019-07-19
    • 2022-07-07
    • 2019-02-23
    • 2022-01-06
    • 2020-06-13
    • 2021-01-25
    • 2021-09-24
    • 1970-01-01
    相关资源
    最近更新 更多