A problem occurred configuring root project ‘android’ Flutter

Error

FAILURE: Build failed with an exception. * What went wrong: A problem occurred configuring project ‘:app’. > Could not open cp_proj generic class cache for build file ‘C:\Users\dharm\AndroidStudioProjects\my_hospital_now\android\app\build.gradle’ (C:\Users\dharm.gradle\caches\7.4.2\scripts\dzntni8anetfv173rjlkkjzu3).

Solution

Whether the first time or not. When you click run on your application you get an X gradle build error If you have any of the following lines in your error even a single line then try this solution

Go this location:- .flutter/packages/flutter_tools/gradle/flutter.gradle

  1. Backup the file in another place before making edits to it
  2. Search for something called buildscript;
  3. It should come up like that (or similar, don’t worry you have a backup file)

And overwrite this code

With this

Still, your problem is not solved? If it was solved DON’T try the next one if not then try it. (And even if this didn’t work then put the backup file in its place and see if it’s working)

Then in your android folder go to build.gradle (in your project files go to android/build.gradle) and change the buildscript to this (Don’t worry about the code not being 100% like this. Just add the specified line in the shown location and that’s it)

Subscribe
Notify of
guest

This site uses Akismet to reduce spam. Learn how your comment data is processed.

0 Comments
Inline Feedbacks
View all comments
0
Would love your thoughts, please comment.x
()
x