Execution failed for task ‘:app:checkDebugDuplicateClasses’

Running into the “Execution failed for task ‘:app:checkDebugDuplicateClasses'” error can have multiple causes. However, if you run into this problem and the error gives you the following information: “A failure occurred while executing com.android.build.gradle.internal.tasks.CheckDuplicatesRunnable” Then this post will have the solution for you.

Cause of the Error

For me, the error was caused in a fresh Flutter project after adding the Share Plus package. Every time I wanted to build the project I got the below error message:

How to Solve Execution failed for task Error

To solve the error, we should start by looking at the given information inside the error message. Therefore we can have a look at the above screenshot, the error message mentions 2 different kotlin-stdlib versions. In this case 1.7.10 and 1.8.22. Keep in mind that these versions could be different for you. However, the solution for the error will remain the same.

Now that we know what versions to look for let us navigate to the settings.gradle file that can be found in the project’s android folder.

Inside the file, you will find the following code:

plugins {
    id "dev.flutter.flutter-plugin-loader" version "1.0.0"
    id "com.android.application" version "7.3.0" apply false
    id "org.jetbrains.kotlin.android" version "1.7.10" apply false
}

As you can see on line 4 version 1.7.10 is mentioned which is one of the versions that was mentioned in the error.

All we have to do now is change this version to 1.8.22 which was the other version that was mentioned in the

plugins {
    id "dev.flutter.flutter-plugin-loader" version "1.0.0"
    id "com.android.application" version "7.3.0" apply false
    id "org.jetbrains.kotlin.android" version "1.8.22" apply false
}

Afterward, if you try to build your project, you will see that it will no longer throw the error.

Conclusion

We have learned how to fix the “Execution failed for task ‘:app:checkDebugDuplicateClasses'” error. Now, you know where to find the versions mentioned in the error message and what changes to make for your build to work.

Tijn van den Eijnde
Tijn van den Eijnde
Articles: 37

Leave a Reply

Your email address will not be published. Required fields are marked *