🚀 DevOps Certified Professional
📅 Starting: 1st of Every Month 🤝 +91 8409492687 | 🤝 +1 (469) 756-6329 🔍 Contact@DevOpsSchool.com

A problem occurred configuring root project ‘android’ Flutter

DevOps

Upgrade & Secure Your Future with DevOps, SRE, DevSecOps, MLOps!

We spend hours on Instagram and YouTube and waste money on coffee and fast food, but won’t spend 30 minutes a day learning skills to boost our careers.
Master in DevOps, SRE, DevSecOps & MLOps!

Learn from Guru Rajesh Kumar and double your salary in just one year.


Get Started Now!

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

buildscript {
repositories {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.1.2'
}
}

With this

buildscript {
repositories {
maven {
url 'https://dl.google.com/dl/android/maven2'
}
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.1.2'
}
}

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)

buildscript {
repositories {
google()
mavenCentral() //add this line
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.2.1' // Doesn't matter what you have here
}
}
Subscribe
Notify of
guest


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

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