首页 > 解决方案 > Flutter:无法确定任务':shared_preferences:compileDebugAidl'的依赖关系

问题描述

我在颤振中创建了新应用程序,运行它时它可以工作,但是当我添加 shared_preferences 包时,运行它时出现此错误

FAILURE: Build failed with an exception.

* What went wrong:
Could not determine the dependencies of task ':shared_preferences:compileDebugAidl'.
> Could not resolve all task dependencies for configuration ':shared_preferences:debugCompileClasspath'.
   > Could not resolve project :shared_preferences_macos.
     Required by:
         project :shared_preferences
      > Unable to find a matching configuration of project :shared_preferences_macos:
          - None of the consumable configurations have attributes.
   > Could not resolve project :shared_preferences_web.
     Required by:
         project :shared_preferences
      > Unable to find a matching configuration of project :shared_preferences_web:
          - None of the consumable configurations have attributes.

* 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 866ms
Gradle task assembleDebug failed with exit code 1

这是我的 pubspec.yaml

dependencies:
  flutter:
    sdk: flutter
  shared_preferences: ^0.5.3+1

  # The following adds the Cupertino Icons font to your application.
  # Use with the CupertinoIcons class for iOS style icons.
  cupertino_icons: ^0.1.2

那有什么问题,我该如何解决?请帮帮我...谢谢

标签: flutterdart

解决方案


我能够通过运行以下命令来解决这个问题:

$ flutter pub cache repair

推荐阅读