Android APK Build Failing "Execution failed for task ':launcher:checkReleaseDuplicateClasses'."

I’m trying to make an APK build but I’m getting the following errors:

FAILURE: Build failed with an exception.
What went wrong:
Execution failed for task ‘:launcher:checkReleaseDuplicateClasses’.
1 exception was raised by workers:
java.lang.RuntimeException: Duplicate class android.support.v4.app.INotificationSideChannel found in modules classes.jar (:androidx.core.core-1.0.0:) and classes.jar (:com.android.support.support-compat-26.1.0:)

…along with 330 other similar errors which I believe to be related. (I will leave the full error message in a comment below).

I’m not very knowledgeable about these sorts of issues so a dumbed-down solution would be appreciated.

I’m having the same issue, I change the Gradle Properties to use Jettifier, change the AndroidManifest.xml but still nothing, would appreciate if someone can help T_T

EDIT

I fixed it by going to AssetsPlay Services ResolverAndroid ResolverDelete Resolved Libraries

Same for me.
I’m using Firebase and Facebook sdk. Everything works perfect on ios but i cant build on android, the only way for it to build is if i completely delete the plugins folder, but then firebase won’t start of course.

Tried using every version of 2019.3 and 2019.4 on mac, same 498 duplicate classes errors everytime.

Also tried:

  • Deleting resolved libraries
  • Resolve / Force Resolve
  • Update version handler
  • disable patch mainTemplate.gradle
  • deleting the sdk 14 or something on firebase AndroidManifest
  • updating and downgrading all plugins (now they are all in their latest version)
  • deleting library
  • deleting the folder, creating a new one and transfering packages and assets folders into it
  • restarting computer
  • everything in every thread ever

:stuck_out_tongue:

I use Mediation for ad. And my solution was just remove the “Advertisement” package on Package Manager from “In Project” tab.

I’ve fixed that issue by deleting the playcore.arr file from the Assets/GooglePlayPlugins/com.google.play.core/Runtime/Plugins folder

https://answers.unity.com/questions/1711904/android-apk-build-failing-execution-failed-for-tas.html,I had the same duplicate classes error but not in the same files, for me it worked deleting one of those files:
androidx.core.core-1.0.0
or
com.android.support.support-compat-26.1.0

The reason I was getting this error was because I had Admob imported and Unity Ads package as well. I deleted Unity Advertisements package from package manager.

I still got this error, when I searched for one of the duplicate files, it was located in my assets folder and the library folder. I closed Unity, deleted Library Folder and then reopened Unity.

It took a long time to rebuild Library folder and after that the build was finally successful.

Hope this helps someone else out struggling with this issue.