How to resolve Flutter build error with the log 'A problem occurred configuring project ':sqflite''

24 views Asked by At

When building flutter apps adding flutterfire configurations that necessitate upgrading the minSdkVersion of the app could cause the following error even when not using the sqflite package.

FAILURE: Build failed with an exception.

  • What went wrong: A problem occurred configuring project ':sqflite'.
  1. Could not load compiled classes for build file 'C:\Users\User\AppData\Local\Pub\Cache\hosted\pub.dev\sqflite-2.3.2\android\build.gradle' from cache.

Failed to notify project evaluation listener. Could not get unknown property 'android' for project ':sqflite' of type org.gradle.api.Project. Could not get unknown property 'android' for project ':sqflite' of type org.gradle.api.Project.

  • 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.

The question has been asked severally but there isn't an answer. Just build logs and error messages. What worked for me and will hopefully work for others is, open the pub cache build.gradle file. C:\Users\User\AppData\Local\Pub\Cache\hosted\pub.dev\sqflite-2.3.2\android\build.gradle

  1. Most likely suspect, change the version number in the buildscript>dependencies>classpath to a newer version. Upgrading mine from 7.4.2 to 8.1.0 worked. Versions here. THis should be enough. If not try next
buildscript {
  repositories {
        google()
        mavenCentral()
    }

    dependencies {
       **classpath 'com.android.tools.build:gradle:7.4.2' change to 8.1.0**
    }
  }
}
  1. Change the minSdkVersion number to the one in your app (21 mostly)
  2. Change the compileSdkVersion to the latest (34 at the time of this post).

Option 1 should solve the error. Remember, the file you're working on is the pub cache file for sqflite, also, flutter clean and flutter pub get.

0

There are 0 answers