Flutter shared_preferences构建失败,但有例外

问题描述 投票:0回答:1

[使用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医生(看是否有错误,但一切正常)
  3. 更改IDE(可视代码和Intellij)
    • 创建新的flutter项目,无需对代码进行任何修改..并且项目运行没有问题

    • [我在pubspec.yaml中添加了http程序包,并单击了程序包get,也没有进行代码修改..并且该项目运行没有问题

      ]
    • 然后我添加了shared preferences pubspec.yaml并单击包get ...,然后单击运行,并出现错误。

    • 我通过获得不同版本的shared preferences和每次遇到相同错误都重复了最后一步。

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

有帮助吗?

android flutter kotlin package sharedpreferences
1个回答
0
投票

对于我来说,我只是跑步:

flutter pub cache repair

之后,该错误将不再发生。希望对您有所帮助

© www.soinside.com 2019 - 2024. All rights reserved.