Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Gradle sync failed: Cause: assert pluginDirectory.exists()

I have the error I put in the title and below. The error occurs when you open Android Studio on folder /android. My project is a Flutter project. I created my project with the Android app Max 2D Game on my Samsung Galaxy A10.

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

I invite you to explore my project on Gitpod or fork on GitHub and submit a pull request fixing this error.

Opening android studio in the android/app folder I get the following error:


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

like image 900
AlexandroGonSan Avatar asked May 10 '26 18:05

AlexandroGonSan


1 Answers

assert pluginDirectory.exists() is returning the error since your pub cache somehow got out of sync.

In such cases, use the command

flutter pub get

from your root folder in order to resync all your dependencies with the cache.

like image 138
Nisanth Reddy Avatar answered May 12 '26 10:05

Nisanth Reddy