Gradle sync failed: Could not create task ':flutter_plugin_android_lifecycle:generateDebugUnitTestConfig'. This and base files have different roots in flutter

In flutter app development sometimes may have seen this error when you go for the release app "Gradle sync failed: Could not create task ':flutter_plugin_android_lifecycle:generateDebugUnitTestConfig'. This and base files have different roots in flutter". I will share with you how to solve easily this error in this post.

Solution :

A simple solution is needed to update with the latest version of Kotlin(ext.kotlin_version = 'latest_version') and gradle of our project. You can see below.

buildscript {
    ext.kotlin_version = '1.7.10' //Update here
    repositories {
        google()
        mavenCentral()
    }

    dependencies {
        classpath 'com.android.tools.build:gradle:7.1.3' //Update here
        classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
        classpath 'com.google.gms:google-services:4.3.10'
        classpath 'com.google.firebase:firebase-crashlytics-gradle:2.9.2'
    }
}

 

You can see in the above code kotlin version is 1.7.10 and gradle version is 7.1.3. which are the latest.

Conclusion:

In this post, we saw how to solve "Gradle sync failed: Could not create task ':flutter_plugin_android_lifecycle:generateDebugUnitTestConfig'. This and base files have different roots in flutter". I hope this post may help you.

 

Tags: