首页 > 解决方案 > Gradle 同步失败:原因:断言 pluginDirectory.exists()

问题描述

我在标题和下面有错误。当您在文件夹 /android 上打开 Android Studio 时会发生错误。我的项目是一个 Flutter 项目。我在三星 Galaxy A10 上使用 Android 应用Max 2D Game创建了我的项目。

Gradle sync failed: Cause: assert pluginDirectory.exists()
                            |               |
                            |               false               > 
                           \root\snap\flutter\common\flutter\.pub-cache\hosted\pub.dartlang.org\audioplayers-0.15.1\android 

我邀请您在Gitpod上探索我的项目或在GitHub 上分叉并提交修复此错误的拉取请求。

在 android/app 文件夹中打开 android studio 我收到以下错误:


FAILURE: Build failed with an exception.

* Where:
Script 'C:\Users\Administrator\Downloads\flutter_windows_2.2.0-stable\flutter\packages\flutter_tools\gradle\app_plugin_loader.gradle' line: 27

* What went wrong:
A problem occurred evaluating script.
> assert pluginDirectory.exists()
         |               |
         |               false
         \root\snap\flutter\common\flutter\.pub-cache\hosted\pub.dartlang.org\audioplayers-0.15.1\android

* 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 121ms

标签: flutterandroid-studio

解决方案


assert pluginDirectory.exists()pub cache由于您以某种方式不同步,因此正在返回错误。

在这种情况下,使用命令

flutter pub get

从您的根文件夹中,以便将所有依赖项与缓存重新同步。


推荐阅读