DuplicateClasses / Build failing / Gradle completely broken

Hi all,

suddenly my build is not working anymore.
When I delete the Ads Mediation (source: package manager) and IronSource Ad Quality (source: Unity Package, see https://developers.is.com/ironsource-mobile/unity/sdk-integration-guides/) packages, the build works.

Picked up JAVA_TOOL_OPTIONS: -Dfile.encoding=UTF-8

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':launcher:checkReleaseDuplicateClasses'.
> A failure occurred while executing com.android.build.gradle.internal.tasks.CheckDuplicatesRunnable
   > Duplicate class android.support.v4.app.INotificationSideChannel found in modules androidx.core.core-1.2.0-runtime (:androidx.core.core-1.2.0:) and core-1.5.0-runtime (androidx.core:core:1.5.0)
     Duplicate class android.support.v4.app.INotificationSideChannel$Stub found in modules androidx.core.core-1.2.0-runtime (:androidx.core.core-1.2.0:) and core-1.5.0-runtime (androidx.core:core:1.5.0)
     Duplicate class android.support.v4.app.INotificationSideChannel$Stub$Proxy found in modules androidx.core.core-1.2.0-runtime (:androidx.core.core-1.2.0:) and core-1.5.0-runtime (androidx.core:core:1.5.0)
     Duplicate class android.support.v4.app.RemoteActionCompatParcelizer found in modules androidx.core.core-1.2.0-runtime (:androidx.core.core-1.2.0:) and core-1.5.0-runtime (androidx.core:core:1.5.0)
     Duplicate class android.support.v4.graphics.drawable.IconCompatParcelizer found in modules androidx.core.core-1.2.0-runtime (:androidx.core.core-1.2.0:) and core-1.5.0-runtime (androidx.core:core:1.5.0)
     Duplicate class android.support.v4.os.IResultReceiver found in modules androidx.core.core-1.2.0-runtime (:androidx.core.core-1.2.0:) and core-1.5.0-runtime (androidx.core:core:1.5.0)
     Duplicate class android.support.v4.os.IResultReceiver$Stub found in modules androidx.core.core-1.2.0-runtime (:androidx.core.core-1.2.0:) and core-1.5.0-runtime (androidx.core:core:1.5.0)
     Duplicate class android.support.v4.os.IResultReceiver$Stub$Proxy found in modules androidx.core.core-1.2.0-runtime (:androidx.core.core-1.2.0:) and core-1.5.0-runtime (androidx.core:core:1.5.0)
     Duplicate class android.support.v4.os.ResultReceiver found in modules androidx.core.core-1.2.0-runtime (:androidx.core.core-1.2.0:) and core-1.5.0-runtime (androidx.core:core:1.5.0)
     Duplicate class android.support.v4.os.ResultReceiver$1 found in modules androidx.core.core-1.2.0-runtime (:androidx.core.core-1.2.0:) and core-1.5.0-runtime (androidx.core:core:1.5.0)
     Duplicate class android.support.v4.os.ResultReceiver$MyResultReceiver found in modules androidx.core.core-1.2.0-runtime (:androidx.core.core-1.2.0:) and core-1.5.0-runtime (androidx.core:core:1.5.0)
     Duplicate class android.support.v4.os.ResultReceiver$MyRunnable found in modules androidx.core.core-1.2.0-runtime (:androidx.core.core-1.2.0:) and core-1.5.0-runtime (androidx.core:core:1.5.0)
     Duplicate class androidx.annotation.AnimRes found in modules androidx.annotation.annotation-1.1.0 (androidx.annotation.annotation-1.1.0.jar) and annotation-1.3.0 (androidx.annotation:annotation:1.3.0)
     Duplicate class androidx.annotation.AnimatorRes found in modules androidx.annotation.annotation-1.1.0 (androidx.annotation.annotation-1.1.0.jar) and annotation-1.3.0 (androidx.annotation:annotation:1.3.0)
     Duplicate class androidx.annotation.AnyRes found in modules androidx.annotation.annotation-1.1.0 (androidx.annotation.annotation-1.1.0.jar) and annotation-1.3.0 (androidx.annotation:annotation:1.3.0)
     Duplicate class androidx.annotation.AnyThread found in modules androidx.annotation.annotation-1.1.0 (androidx.annotation.annotation-1.1.0.jar) and annotation-1.3.0 (androidx.annotation:annotation:1.3.0)
     Duplicate class androidx.annotation.ArrayRes found in modules androidx.annotation.annotation-1.1.0 (androidx.annotation.annotation-1.1.0.jar) and annotation-1.3.0 (androidx.annotation:annotation:1.3.0)
     Duplicate class androidx.annotation.AttrRes found in modules androidx.annotation.annotation-1.1.0 (androidx.annotation.annotation-1.1.0.jar) and annotation-1.3.0 (androidx.annotation:annotation:1.3.0)
     Duplicate class androidx.annotation.BinderThread found in modules androidx.annotation.annotation-1.1.0 (androidx.annotation.annotation-1.1.0.jar) and annotation-1.3.0 (androidx.annotation:annotation:1.3.0)
     Duplicate class androidx.annotation.BoolRes found in modules androidx.annotation.annotation-1.1.0 (androidx.annotation.annotation-1.1.0.jar) and annotation-1.3.0 (androidx.annotation:annotation:1.3.0)
     Duplicate class androidx.annotation.CallSuper found in modules androidx.annotation.annotation-1.1.0 (androidx.annotation.annotation-1.1.0.jar) and annotation-1.3.0 (androidx.annotation:annotation:1.3.0)
     Duplicate class androidx.annotation.CheckResult found in modules androidx.annotation.annotation-1.1.0 (androidx.annotation.annotation-1.1.0.jar) and annotation-1.3.0 (androidx.annotation:annotation:1.3.0)
     Duplicate class androidx.annotation.ColorInt found in modules androidx.annotation.annotation-1.1.0 (androidx.annotation.annotation-1.1.0.jar) and annotation-1.3.0 (androidx.annotation:annotation:1.3.0)
     Duplicate class androidx.annotation.ColorLong found in modules androidx.annotation.annotation-1.1.0 (androidx.annotation.annotation-1.1.0.jar) and annotation-1.3.0 (androidx.annotation:annotation:1.3.0)
     Duplicate class androidx.annotation.ColorRes found in modules androidx.annotation.annotation-1.1.0 (androidx.annotation.annotation-1.1.0.jar) and annotation-1.3.0 (androidx.annotation:annotation:1.3.0)
     Duplicate class androidx.annotation.ContentView found in modules androidx.annotation.annotation-1.1.0 (androidx.annotation.annotation-1.1.0.jar) and annotation-1.3.0 (androidx.annotation:annotation:1.3.0)
     Duplicate class androidx.annotation.DimenRes found in modules androidx.annotation.annotation-1.1.0 (androidx.annotation.annotation-1.1.0.jar) and annotation-1.3.0 (androidx.annotation:annotation:1.3.0)
     Duplicate class androidx.annotation.Dimension found in modules androidx.annotation.annotation-1.1.0 (androidx.annotation.annotation-1.1.0.jar) and annotation-1.3.0 (androidx.annotation:annotation:1.3.0)
     Duplicate class androidx.annotation.DrawableRes found in modules androidx.annotation.annotation-1.1.0 (androidx.annotation.annotation-1.1.0.jar) and annotation-1.3.0 (androidx.annotation:annotation:1.3.0)
     Duplicate class androidx.annotation.FloatRange found in modules androidx.annotation.annotation-1.1.0 (androidx.annotation.annotation-1.1.0.jar) and annotation-1.3.0 (androidx.annotation:annotation:1.3.0)
     Duplicate class androidx.annotation.FontRes found in modules androidx.annotation.annotation-1.1.0 (androidx.annotation.annotation-1.1.0.jar) and annotation-1.3.0 (androidx.annotation:annotation:1.3.0)
     Duplicate class androidx.annotation.FractionRes found in modules androidx.annotation.annotation-1.1.0 (androidx.annotation.annotation-1.1.0.jar) and annotation-1.3.0 (androidx.annotation:annotation:1.3.0)
     Duplicate class androidx.annotation.GuardedBy found in modules androidx.annotation.annotation-1.1.0 (androidx.annotation.annotation-1.1.0.jar) and annotation-1.3.0 (androidx.annotation:annotation:1.3.0)
     Duplicate class androidx.annotation.HalfFloat found in modules androidx.annotation.annotation-1.1.0 (androidx.annotation.annotation-1.1.0.jar) and annotation-1.3.0 (androidx.annotation:annotation:1.3.0)
     Duplicate class androidx.annotation.IdRes found in modules androidx.annotation.annotation-1.1.0 (androidx.annotation.annotation-1.1.0.jar) and annotation-1.3.0 (androidx.annotation:annotation:1.3.0)
     Duplicate class androidx.annotation.InspectableProperty found in modules androidx.annotation.annotation-1.1.0 (androidx.annotation.annotation-1.1.0.jar) and annotation-1.3.0 (androidx.annotation:annotation:1.3.0)
     Duplicate class androidx.annotation.InspectableProperty$EnumEntry found in modules androidx.annotation.annotation-1.1.0 (androidx.annotation.annotation-1.1.0.jar) and annotation-1.3.0 (androidx.annotation:annotation:1.3.0)
     Duplicate class androidx.annotation.InspectableProperty$FlagEntry found in modules androidx.annotation.annotation-1.1.0 (androidx.annotation.annotation-1.1.0.jar) and annotation-1.3.0 (androidx.annotation:annotation:1.3.0)
     Duplicate class androidx.annotation.InspectableProperty$ValueType found in modules androidx.annotation.annotation-1.1.0 (androidx.annotation.annotation-1.1.0.jar) and annotation-1.3.0 (androidx.annotation:annotation:1.3.0)
     Duplicate class androidx.annotation.IntDef found in modules androidx.annotation.annotation-1.1.0 (androidx.annotation.annotation-1.1.0.jar) and annotation-1.3.0 (androidx.annotation:annotation:1.3.0)
     Duplicate class androidx.annotation.IntRange found in modules androidx.annotation.annotation-1.1.0 (androidx.annotation.annotation-1.1.0.jar) and annotation-1.3.0 (androidx.annotation:annotation:1.3.0)
     Duplicate class androidx.annotation.IntegerRes found in modules androidx.annotation.annotation-1.1.0 (androidx.annotation.annotation-1.1.0.jar) and annotation-1.3.0 (androidx.annotation:annotation:1.3.0)
     Duplicate class androidx.annotation.InterpolatorRes found in modules androidx.annotation.annotation-1.1.0 (androidx.annotation.annotation-1.1.0.jar) and annotation-1.3.0 (androidx.annotation:annotation:1.3.0)
     Duplicate class androidx.annotation.Keep found in modules androidx.annotation.annotation-1.1.0 (androidx.annotation.annotation-1.1.0.jar) and annotation-1.3.0 (androidx.annotation:annotation:1.3.0)
     Duplicate class androidx.annotation.LayoutRes found in modules androidx.annotation.annotation-1.1.0 (androidx.annotation.annotation-1.1.0.jar) and annotation-1.3.0 (androidx.annotation:annotation:1.3.0)
     Duplicate class androidx.annotation.LongDef found in modules androidx.annotation.annotation-1.1.0 (androidx.annotation.annotation-1.1.0.jar) and annotation-1.3.0 (androidx.annotation:annotation:1.3.0)
     Duplicate class androidx.annotation.MainThread found in modules androidx.annotation.annotation-1.1.0 (androidx.annotation.annotation-1.1.0.jar) and annotation-1.3.0 (androidx.annotation:annotation:1.3.0)
     Duplicate class androidx.annotation.MenuRes found in modules androidx.annotation.annotation-1.1.0 (androidx.annotation.annotation-1.1.0.jar) and annotation-1.3.0 (androidx.annotation:annotation:1.3.0)
     Duplicate class androidx.annotation.NavigationRes found in modules androidx.annotation.annotation-1.1.0 (androidx.annotation.annotation-1.1.0.jar) and annotation-1.3.0 (androidx.annotation:annotation:1.3.0)
     Duplicate class androidx.annotation.NonNull found in modules androidx.annotation.annotation-1.1.0 (androidx.annotation.annotation-1.1.0.jar) and annotation-1.3.0 (androidx.annotation:annotation:1.3.0)
     Duplicate class androidx.annotation.Nullable found in modules androidx.annotation.annotation-1.1.0 (androidx.annotation.annotation-1.1.0.jar) and annotation-1.3.0 (androidx.annotation:annotation:1.3.0)
     Duplicate class androidx.annotation.PluralsRes found in modules androidx.annotation.annotation-1.1.0 (androidx.annotation.annotation-1.1.0.jar) and annotation-1.3.0 (androidx.annotation:annotation:1.3.0)
     Duplicate class androidx.annotation.Px found in modules androidx.annotation.annotation-1.1.0 (androidx.annotation.annotation-1.1.0.jar) and annotation-1.3.0 (androidx.annotation:annotation:1.3.0)
     Duplicate class androidx.annotation.RawRes found in modules androidx.annotation.annotation-1.1.0 (androidx.annotation.annotation-1.1.0.jar) and annotation-1.3.0 (androidx.annotation:annotation:1.3.0)
     Duplicate class androidx.annotation.RequiresApi found in modules androidx.annotation.annotation-1.1.0 (androidx.annotation.annotation-1.1.0.jar) and annotation-1.3.0 (androidx.annotation:annotation:1.3.0)
     Duplicate class androidx.annotation.RequiresFeature found in modules androidx.annotation.annotation-1.1.0 (androidx.annotation.annotation-1.1.0.jar) and annotation-1.3.0 (androidx.annotation:annotation:1.3.0)
     Duplicate class androidx.annotation.RequiresPermission found in modules androidx.annotation.annotation-1.1.0 (androidx.annotation.annotation-1.1.0.jar) and annotation-1.3.0 (androidx.annotation:annotation:1.3.0)
     Duplicate class androidx.annotation.RequiresPermission$Read found in modules androidx.annotation.annotation-1.1.0 (androidx.annotation.annotation-1.1.0.jar) and annotation-1.3.0 (androidx.annotation:annotation:1.3.0)
     Duplicate class androidx.annotation.RequiresPermission$Write found in modules androidx.annotation.annotation-1.1.0 (androidx.annotation.annotation-1.1.0.jar) and annotation-1.3.0 (androidx.annotation:annotation:1.3.0)
     Duplicate class androidx.annotation.RestrictTo found in modules androidx.annotation.annotation-1.1.0 (androidx.annotation.annotation-1.1.0.jar) and annotation-1.3.0 (androidx.annotation:annotation:1.3.0)
     Duplicate class androidx.annotation.RestrictTo$Scope found in modules androidx.annotation.annotation-1.1.0 (androidx.annotation.annotation-1.1.0.jar) and annotation-1.3.0 (androidx.annotation:annotation:1.3.0)
     Duplicate class androidx.annotation.Size found in modules androidx.annotation.annotation-1.1.0 (androidx.annotation.annotation-1.1.0.jar) and annotation-1.3.0 (androidx.annotation:annotation:1.3.0)
     Duplicate class androidx.annotation.StringDef found in modules androidx.annotation.annotation-1.1.0 (androidx.annotation.annotation-1.1.0.jar) and annotation-1.3.0 (androidx.annotation:annotation:1.3.0)
     Duplicate class androidx.annotation.StringRes found in modules androidx.annotation.annotation-1.1.0 (androidx.annotation.annotation-1.1.0.jar) and annotation-1.3.0 (androidx.annotation:annotation:1.3.0)
     Duplicate class androidx.annotation.StyleRes found in modules androidx.annotation.annotation-1.1.0 (androidx.annotation.annotation-1.1.0.jar) and annotation-1.3.0 (androidx.annotation:annotation:1.3.0)
     Duplicate class androidx.annotation.StyleableRes found in modules androidx.annotation.annotation-1.1.0 (androidx.annotation.annotation-1.1.0.jar) and annotation-1.3.0 (androidx.annotation:annotation:1.3.0)
     Duplicate class androidx.annotation.TransitionRes found in modules androidx.annotation.annotation-1.1.0 (androidx.annotation.annotation-1.1.0.jar) and annotation-1.3.0 (androidx.annotation:annotation:1.3.0)
     Duplicate class androidx.annotation.UiThread found in modules androidx.annotation.annotation-1.1.0 (androidx.annotation.annotation-1.1.0.jar) and annotation-1.3.0 (androidx.annotation:annotation:1.3.0)
     Duplicate class androidx.annotation.VisibleForTesting found in modules androidx.annotation.annotation-1.1.0 (androidx.annotation.annotation-1.1.0.jar) and annotation-1.3.0 (androidx.annotation:annotation:1.3.0)
     Duplicate class androidx.annotation.WorkerThread found in modules androidx.annotation.annotation-1.1.0 (androidx.annotation.annotation-1.1.0.jar) and annotation-1.3.0 (androidx.annotation:annotation:1.3.0)
     Duplicate class androidx.annotation.XmlRes found in modules androidx.annotation.annotation-1.1.0 (androidx.annotation.annotation-1.1.0.jar) and annotation-1.3.0 (androidx.annotation:annotation:1.3.0)
     Duplicate class androidx.arch.core.executor.ArchTaskExecutor found in modules androidx.arch.core.core-runtime-2.0.0-runtime (:androidx.arch.core.core-runtime-2.0.0:) and core-runtime-2.1.0-runtime (androidx.arch.core:core-runtime:2.1.0)
     Duplicate class androidx.arch.core.executor.ArchTaskExecutor$1 found in modules androidx.arch.core.core-runtime-2.0.0-runtime (:androidx.arch.core.core-runtime-2.0.0:) and core-runtime-2.1.0-runtime (androidx.arch.core:core-runtime:2.1.0)
     Duplicate class androidx.arch.core.executor.ArchTaskExecutor$2 found in modules androidx.arch.core.core-runtime-2.0.0-runtime (:androidx.arch.core.core-runtime-2.0.0:) and core-runtime-2.1.0-runtime (androidx.arch.core:core-runtime:2.1.0)
     Duplicate class androidx.arch.core.executor.DefaultTaskExecutor found in modules androidx.arch.core.core-runtime-2.0.0-runtime (:androidx.arch.core.core-runtime-2.0.0:) and core-runtime-2.1.0-runtime (androidx.arch.core:core-runtime:2.1.0)
     Duplicate class androidx.arch.core.executor.DefaultTaskExecutor$1 found in modules androidx.arch.core.core-runtime-2.0.0-runtime (:androidx.arch.core.core-runtime-2.0.0:) and core-runtime-2.1.0-runtime (androidx.arch.core:core-runtime:2.1.0)
     Duplicate class androidx.ar<message truncated>

When I do ā€œAssets > External Dependency Manager > Android Resolver > Delete resolved Librariesā€ the build works once, but then I get the following error on start: java.lang.NoClassDefFoundError. Failed reoslution of: Lcom/ironsource/mediationsdk/InitializationListener;

Regarding my publishing settings, I am currently using no manual configs / manifests:

Unity Version: 2022.3.20f1

I am in despair with my project… any help would be much appreciated!
Cheers

As per the error you have two core libraries 1.2.0 and 1.5.0 versions included in the project. You either need to delete/disable one of those.

They seem to be the result of dependency resolution, how can I disable them?

Also my Assets/Plugins/Android directory only contains androidx.core.core-1.2.0 after resolving dependencies, I dont know where the other version is comming from.

Try this.

  1. Enable Custom Main Gradle Template in player settings (android)
  2. Force resolve
  3. Share the main gradle template(Assets/Plugins/Android folder) file here.

Thanks for your suggestion.
I deleted all resolved libraries, enabled the custom main gradle template and hit ā€˜Force resolve’.
Here are the contents of my mainTemplate.gradle:

apply plugin: 'com.android.library'
**APPLY_PLUGINS**

dependencies {
    implementation fileTree(dir: 'libs', include: ['*.jar'])
**DEPS**}

android {
    ndkPath "**NDKPATH**"

    compileSdkVersion **APIVERSION**
    buildToolsVersion '**BUILDTOOLS**'

    compileOptions {
        sourceCompatibility JavaVersion.VERSION_11
        targetCompatibility JavaVersion.VERSION_11
    }

    defaultConfig {
        minSdkVersion **MINSDKVERSION**
        targetSdkVersion **TARGETSDKVERSION**
        ndk {
            abiFilters **ABIFILTERS**
        }
        versionCode **VERSIONCODE**
        versionName '**VERSIONNAME**'
        consumerProguardFiles 'proguard-unity.txt'**USER_PROGUARD**
    }

    lintOptions {
        abortOnError false
    }

    aaptOptions {
        noCompress = **BUILTIN_NOCOMPRESS** + unityStreamingAssets.tokenize(', ')
        ignoreAssetsPattern = "!.svn:!.git:!.ds_store:!*.scc:!CVS:!thumbs.db:!picasa.ini:!*~"
    }**PACKAGING_OPTIONS**
}
**IL_CPP_BUILD_SETUP**
**SOURCE_BUILD_SETUP**
**EXTERNAL_SOURCES**

I see EDMU didn’t attach any dependencies. Is it like your project doesn’t have any or am I missing something?

I think it has for sure: I am using Google Play Libraries for In App Update, AdsMediation and IronSourceAdQualitySDK.

I think that AdsMediation/IronSource is the cause of all this trouble.

Also what I noted: even when removing IronSourceAdQualitySDK and AdsMediation package (and all related folders in Assets folder, e.g. LevelPlay etc) and then perform ā€œRevolve Librariesā€, the popping up Dialog still shows me some IronSource libraries. I cant copy the message at the moment but it was something like ā€œLibraries to copy: com.google.inappupdate, com.ironsourceā€¦ā€

First check if you have any orphan dependency xml files. Also, delete resolved libraries from EDMU and force resolve. It should populate the dependencies in main gradle template.
If its not populating, check if Patch Main Gradle Templte is enabled in EDMU settings or not.

IronSource / Ads Mediation was not the culprit.

Deleting the ExternalDependencyManager folder and reinstalling the plugin has helped. I dont know why it suddenly stopped working but something broke at some point. I also had 2 versions of the plugin installed at the same time, which may be bad, although it worked for over a year.

Now Google Play InAppUpdate is also working properly again.
Thanks for your attention @Voxel-Busters !

Great! Glad you figured it out.

EDMU not updating the dependencies when main gradle template available was something strange. But didnt expect EDMU version going wrong.

Hi @g3nuine3
Which versions do you have? I have the same problem with:

Thanks

I have the same versions except that I use Unity 2022.3.35f1

Thank you.
I solved my problem by:

  • Removing ā€œMobileDependecyResolverā€ (the one shipped with LevelPlay) and install last version of EDMU from github
  • Deleting my old custom/launcher/… gradle templates in plugins/Android then checking again in the player Settings all the custom templates.
  • Check the ā€œPatch mainTemplate.gradleā€ in the Android Resolver Settings (so now aar are not copied in Plugins/Android but added as dependecies in mainTemplate.
    Then it works!