Search Unity

Duplicate class Android on build

Discussion in 'Editor & General Support' started by Studio6D, Jul 19, 2021.

  1. Studio6D

    Studio6D

    Joined:
    Jun 10, 2021
    Posts:
    11
    Hello,

    When I build my application to Android, I get this error:

    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.RemoteActionCompatParcelizer found in modules classes.jar (:androidx.core.core-1.3.0:) and classes.jar (androidx.core:core:1.1.0)
    Duplicate class android.support.v4.graphics.drawable.IconCompatParcelizer found in modules classes.jar (:androidx.core.core-1.3.0:) and classes.jar (androidx.core:core:1.1.0)
    Duplicate class android.support.v4.os.ResultReceiver found in modules classes.jar (:androidx.core.core-1.3.0:) and classes.jar (androidx.core:core:1.1.0)
    Duplicate class android.support.v4.os.ResultReceiver$1 found in modules classes.jar (:androidx.core.core-1.3.0:) and classes.jar (androidx.core:core:1.1.0)
    Duplicate class android.support.v4.os.ResultReceiver$MyResultReceiver found in modules classes.jar (:androidx.core.core-1.3.0:) and classes.jar (androidx.core:core:1.1.0)
    Duplicate class android.support.v4.os.ResultReceiver$MyRunnable found in modules classes.jar (:androidx.core.core-1.3.0:) and classes.jar (androidx.core:core:1.1.0)
    Duplicate class androidx.annotation.AnimRes found in modules androidx.annotation.annotation-1.1.0.jar (androidx.annotation.annotation-1.1.0.jar) and annotation-1.1.0.jar (androidx.annotation:annotation:1.1.0)
    Duplicate class androidx.annotation.AnimatorRes found in modules androidx.annotation.annotation-1.1.0.jar (androidx.annotation.annotation-1.1.0.jar) and annotation-1.1.0.jar (androidx.annotation:annotation:1.1.0)
    Duplicate class androidx.annotation.AnyRes found in modules androidx.annotation.annotation-1.1.0.jar (androidx.annotation.annotation-1.1.0.jar) and annotation-1.1.0.jar (androidx.annotation:annotation:1.1.0)
    Duplicate class androidx.annotation.AnyThread found in modules androidx.annotation.annotation-1.1.0.jar (androidx.annotation.annotation-1.1.0.jar) and annotation-1.1.0.jar (androidx.annotation:annotation:1.1.0)
    Duplicate class androidx.annotation.ArrayRes found in modules androidx.annotation.annotation-1.1.0.jar (androidx.annotation.annotation-1.1.0.jar) and annotation-1.1.0.jar (androidx.annotation:annotation:1.1.0)
    Duplicate class androidx.annotation.AttrRes found in modules androidx.annotation.annotation-1.1.0.jar (androidx.annotation.annotation-1.1.0.jar) and annotation-1.1.0.jar (androidx.annotation:annotation:1.1.0)
    Duplicate class androidx.annotation.BinderThread found in modules androidx.annotation.annotation-1.1.0.jar (androidx.annotation.annotation-1.1.0.jar) and annotation-1.1.0.jar (androidx.annotation:annotation:1.1.0)
    Duplicate class androidx.annotation.BoolRes found in modules androidx.annotation.annotation-1.1.0.jar (androidx.annotation.annotation-1.1.0.jar) and annotation-1.1.0.jar (androidx.annotation:annotation:1.1.0)
    Duplicate class androidx.annotation.CallSuper found in modules androidx.annotation.annotation-1.1.0.jar (androidx.annotation.annotation-1.1.0.jar) and annotation-1.1.0.jar (androidx.annotation:annotation:1.1.0)
    Duplicate class androidx.annotation.CheckResult found in modules androidx.annotation.annotation-1.1.0.jar (androidx.annotation.annotation-1.1.0.jar) and annotation-1.1.0.jar (androidx.annotation:annotation:1.1.0)
    Duplicate class androidx.annotation.ColorInt found in modules androidx.annotation.annotation-1.1.0.jar (androidx.annotation.annotation-1.1.0.jar) and annotation-1.1.0.jar (androidx.annotation:annotation:1.1.0)
    Duplicate class androidx.annotation.ColorLong found in modules androidx.annotation.annotation-1.1.0.jar (androidx.annotation.annotation-1.1.0.jar) and annotation-1.1.0.jar (androidx.annotation:annotation:1.1.0)
    Duplicate class androidx.annotation.ColorRes found in modules androidx.annotation.annotation-1.1.0.jar (androidx.annotation.annotation-1.1.0.jar) and annotation-1.1.0.jar (androidx.annotation:annotation:1.1.0)
    Duplicate class androidx.annotation.ContentView found in modules androidx.annotation.annotation-1.1.0.jar (androidx.annotation.annotation-1.1.0.jar) and annotation-1.1.0.jar (androidx.annotation:annotation:1.1.0)
    Duplicate class androidx.annotation.DimenRes found in modules androidx.annotation.annotation-1.1.0.jar (androidx.annotation.annotation-1.1.0.jar) and annotation-1.1.0.jar (androidx.annotation:annotation:1.1.0)
    Duplicate class androidx.annotation.Dimension found in modules androidx.annotation.annotation-1.1.0.jar (androidx.annotation.annotation-1.1.0.jar) and annotation-1.1.0.jar (androidx.annotation:annotation:1.1.0)
    Duplicate class androidx.annotation.DrawableRes found in modules androidx.annotation.annotation-1.1.0.jar (androidx.annotation.annotation-1.1.0.jar) and annotation-1.1.0.jar (androidx.annotation:annotation:1.1.0)
    Duplicate class androidx.annotation.FloatRange found in modules androidx.annotation.annotation-1.1.0.jar (androidx.annotation.annotation-1.1.0.jar) and annotation-1.1.0.jar (androidx.annotation:annotation:1.1.0)
    Duplicate class androidx.annotation.FontRes found in modules androidx.annotation.annotation-1.1.0.jar (androidx.annotation.annotation-1.1.0.jar) and annotation-1.1.0.jar (androidx.annotation:annotation:1.1.0)
    Duplicate class androidx.annotation.FractionRes found in modules androidx.annotation.annotation-1.1.0.jar (androidx.annotation.annotation-1.1.0.jar) and annotation-1.1.0.jar (androidx.annotation:annotation:1.1.0)
    Duplicate class androidx.annotation.GuardedBy found in modules androidx.annotation.annotation-1.1.0.jar (androidx.annotation.annotation-1.1.0.jar) and annotation-1.1.0.jar (androidx.annotation:annotation:1.1.0)
    Duplicate class androidx.annotation.HalfFloat found in modules androidx.annotation.annotation-1.1.0.jar (androidx.annotation.annotation-1.1.0.jar) and annotation-1.1.0.jar (androidx.annotation:annotation:1.1.0)
    Duplicate class androidx.annotation.IdRes found in modules androidx.annotation.annotation-1.1.0.jar (androidx.annotation.annotation-1.1.0.jar) and annotation-1.1.0.jar (androidx.annotation:annotation:1.1.0)
    Duplicate class androidx.annotation.InspectableProperty found in modules androidx.annotation.annotation-1.1.0.jar (androidx.annotation.annotation-1.1.0.jar) and annotation-1.1.0.jar (androidx.annotation:annotation:1.1.0)
    Duplicate class androidx.annotation.InspectableProperty$EnumEntry found in modules androidx.annotation.annotation-1.1.0.jar (androidx.annotation.annotation-1.1.0.jar) and annotation-1.1.0.jar (androidx.annotation:annotation:1.1.0)
    Duplicate class androidx.annotation.InspectableProperty$FlagEntry found in modules androidx.annotation.annotation-1.1.0.jar (androidx.annotation.annotation-1.1.0.jar) and annotation-1.1.0.jar (androidx.annotation:annotation:1.1.0)
    Duplicate class androidx.annotation.InspectableProperty$ValueType found in modules androidx.annotation.annotation-1.1.0.jar (androidx.annotation.annotation-1.1.0.jar) and annotation-1.1.0.jar (androidx.annotation:annotation:1.1.0)
    Duplicate class androidx.annotation.IntDef found in modules androidx.annotation.annotation-1.1.0.jar (androidx.annotation.annotation-1.1.0.jar) and annotation-1.1.0.jar (androidx.annotation:annotation:1.1.0)
    Duplicate class androidx.annotation.IntRange found in modules androidx.annotation.annotation-1.1.0.jar (androidx.annotation.annotation-1.1.0.jar) and annotation-1.1.0.jar (androidx.annotation:annotation:1.1.0)
    Duplicate class androidx.annotation.IntegerRes found in modules androidx.annotation.annotation-1.1.0.jar (androidx.annotation.annotation-1.1.0.jar) and annotation-1.1.0.jar (androidx.annotation:annotation:1.1.0)
    Duplicate class androidx.annotation.InterpolatorRes found in modules androidx.annotation.annotation-1.1.0.jar (androidx.annotation.annotation-1.1.0.jar) and annotation-1.1.0.jar (androidx.annotation:annotation:1.1.0)
    Duplicate class androidx.annotation.Keep found in modules androidx.annotation.annotation-1.1.0.jar (androidx.annotation.annotation-1.1.0.jar) and annotation-1.1.0.jar (androidx.annotation:annotation:1.1.0)
    Duplicate class androidx.annotation.LayoutRes found in modules androidx.annotation.annotation-1.1.0.jar (androidx.annotation.annotation-1.1.0.jar) and annotation-1.1.0.jar (androidx.annotation:annotation:1.1.0)
    Duplicate class androidx.annotation.LongDef found in modules androidx.annotation.annotation-1.1.0.jar (androidx.annotation.annotation-1.1.0.jar) and annotation-1.1.0.jar (androidx.annotation:annotation:1.1.0)
    Duplicate class androidx.annotation.MainThread found in modules androidx.annotation.annotation-1.1.0.jar (androidx.annotation.annotation-1.1.0.jar) and annotation-1.1.0.jar (androidx.annotation:annotation:1.1.0)
    Duplicate class androidx.annotation.MenuRes found in modules androidx.annotation.annotation-1.1.0.jar (androidx.annotation.annotation-1.1.0.jar) and annotation-1.1.0.jar (androidx.annotation:annotation:1.1.0)
    Duplicate class androidx.annotation.NavigationRes found in modules androidx.annotation.annotation-1.1.0.jar (androidx.annotation.annotation-1.1.0.jar) and annotation-1.1.0.jar (androidx.annotation:annotation:1.1.0)
    Duplicate class androidx.annotation.NonNull found in modules androidx.annotation.annotation-1.1.0.jar (androidx.annotation.annotation-1.1.0.jar) and annotation-1.1.0.jar (androidx.annotation:annotation:1.1.0)
    Duplicate class androidx.annotation.Nullable found in modules androidx.annotation.annotation-1.1.0.jar (androidx.annotation.annotation-1.1.0.jar) and annotation-1.1.0.jar (androidx.annotation:annotation:1.1.0)
    Duplicate class androidx.annotation.PluralsRes found in modules androidx.annotation.annotation-1.1.0.jar (androidx.annotation.annotation-1.1.0.jar) and annotation-1.1.0.jar (androidx.annotation:annotation:1.1.0)
    Duplicate class androidx.annotation.Px found in modules androidx.annotation.annotation-1.1.0.jar (androidx.annotation.annotation-1.1.0.jar) and annotation-1.1.0.jar (androidx.annotation:annotation:1.1.0)
    Duplicate class androidx.annotation.RawRes found in modules androidx.annotation.annotation-1.1.0.jar (androidx.annotation.annotation-1.1.0.jar) and annotation-1.1.0.jar (androidx.annotation:annotation:1.1.0)
    Duplicate class androidx.annotation.RequiresApi found in modules androidx.annotation.annotation-1.1.0.jar (androidx.annotation.annotation-1.1.0.jar) and annotation-1.1.0.jar (androidx.annotation:annotation:1.1.0)
    Duplicate class androidx.annotation.RequiresFeature found in modules androidx.annotation.annotation-1.1.0.jar (androidx.annotation.annotation-1.1.0.jar) and annotation-1.1.0.jar (androidx.annotation:annotation:1.1.0)
    Duplicate class androidx.annotation.RequiresPermission found in modules androidx.annotation.annotation-1.1.0.jar (androidx.annotation.annotation-1.1.0.jar) and annotation-1.1.0.jar (androidx.annotation:annotation:1.1.0)
    Duplicate class androidx.annotation.RequiresPermission$Read found in modules androidx.annotation.annotation-1.1.0.jar (androidx.annotation.annotation-1.1.0.jar) and annotation-1.1.0.jar (androidx.annotation:annotation:1.1.0)
    Duplicate class androidx.annotation.RequiresPermission$Write found in modules androidx.annotation.annotation-1.1.0.jar (androidx.annotation.annotation-1.1.0.jar) and annotation-1.1.0.jar (androidx.annotation:annotation:1.1.0)
    Duplicate class androidx.annotation.RestrictTo found in modules androidx.annotation.annotation-1.1.0.jar (androidx.annotation.annotation-1.1.0.jar) and annotation-1.1.0.jar (androidx.annotation:annotation:1.1.0)
    Duplicate class androidx.annotation.RestrictTo$Scope found in modules androidx.annotation.annotation-1.1.0.jar (androidx.annotation.annotation-1.1.0.jar) and annotation-1.1.0.jar (androidx.annotation:annotation:1.1.0)
    Duplicate class androidx.annotation.Size found in modules androidx.annotation.annotation-1.1.0.jar (androidx.annotation.annotation-1.1.0.jar) and annotation-1.1.0.jar (androidx.annotation:annotation:1.1.0)
    Duplicate class androidx.annotation.StringDef found in modules androidx.annotation.annotation-1.1.0.jar (androidx.annotation.annotation-1.1.0.jar) and annotation-1.1.0.jar (androidx.annotation:annotation:1.1.0)
    Duplicate class androidx.annotation.StringRes found in modules androidx.annotation.annotation-1.1.0.jar (androidx.annotation.annotation-1.1.0.jar) and annotation-1.1.0.jar (androidx.annotation:annotation:1.1.0)
    Duplicate class androidx.annotation.StyleRes found in modules androidx.annotation.annotation-1.1.0.jar (androidx.annotation.annotation-1.1.0.jar) and annotation-1.1.0.jar (androidx.annotation:annotation:1.1.0)
    Duplicate class androidx.annotation.StyleableRes found in modules androidx.annotation.annotation-1.1.0.jar (androidx.annotation.annotation-1.1.0.jar) and annotation-1.1.0.jar (androidx.annotation:annotation:1.1.0)
    Duplicate class androidx.annotation.TransitionRes found in modules androidx.annotation.annotation-1.1.0.jar (androidx.annotation.annotation-1.1.0.jar) and annotation-1.1.0.jar (androidx.annotation:annotation:1.1.0)
    Duplicate class androidx.annotation.UiThread found in modules androidx.annotation.annotation-1.1.0.jar (androidx.annotation.annotation-1.1.0.jar) and annotation-1.1.0.jar (androidx.annotation:annotation:1.1.0)
    Duplicate class androidx.annotation.VisibleForTesting found in modules androidx.annotation.annotation-1.1.0.jar (androidx.annotation.annotation-1.1.0.jar) and annotation-1.1.0.jar (androidx.annotation:annotation:1.1.0)
    Duplicate class androidx.annotation.WorkerThread found in modules androidx.annotation.annotation-1.1.0.jar (androidx.annotation.annotation-1.1.0.jar) and annotation-1.1.0.jar (androidx.annotation:annotation:1.1.0)
    Duplicate class androidx.annotation.XmlRes found in modules androidx.annotation.annotation-1.1.0.jar (androidx.annotation.annotation-1.1.0.jar) and annotation-1.1.0.jar (androidx.annotation:annotation:1.1.0)
    Duplicate class androidx.arch.core.internal.FastSafeIterableMap found in modules androidx.arch.core.core-common-2.0.0.jar (androidx.arch.core.core-common-2.0.0.jar) and core-common-2.0.0.jar (androidx.arch.core:core-common:2.0.0)
    Duplicate class androidx.arch.core.internal.SafeIterableMap found in modules androidx.arch.core.core-common-2.0.0.jar (androidx.arch.core.core-common-2.0.0.jar) and core-common-2.0.0.jar (androidx.arch.core:core-common:2.0.0)
    Duplicate class androidx.arch.core.internal.SafeIterableMap$AscendingIterator found in modules androidx.arch.core.core-common-2.0.0.jar (androidx.arch.core.core-common-2.0.0.jar) and core-common-2.0.0.jar (androidx.arch.core:core-common:2.0.0)
    Duplicate class androidx.arch.core.internal.SafeIterableMap$DescendingIterator found in modules androidx.arch.core.core-common-2.0.0.jar (androidx.arch.core.core-common-2.0.0.jar) and core-common-2.0.0.jar (androidx.arch.core:core-common:2.0.0)
    Duplicate class androidx.arch.core.internal.SafeIterableMap$Entry found in modules androidx.arch.core.core-common-2.0.0.jar (androidx.arch.core.core-common-2.0.0.jar) and core-common-2.0.0.jar (androidx.arch.core:core-common:2.0.0)
    Duplicate class androidx.arch.core.internal.SafeIterableMap$IteratorWithAdditions found in modules androidx.arch.core.core-common-2.0.0.jar (androidx.arch.core.core-common-2.0.0.jar) and core-common-2.0.0.jar (androidx.arch.core:core-common:2.0.0)
    Duplicate class androidx.arch.core.internal.SafeIterableMap$ListIterator found in modules androidx.arch.core.core-common-2.0.0.jar (androidx.arch.core.core-common-2.0.0.jar) and core-common-2.0.0.jar (androidx.arch.core:core-common:2.0.0)
    Duplicate class androidx.arch.core.internal.SafeIterableMap$SupportRemove found in modules androidx.arch.core.core-common-2.0.0.jar (androidx.arch.core.core-common-2.0.0.jar) and core-common-2.0.0.jar (androidx.arch.core:core-common:2.0.0)
    Duplicate class androidx.arch.core.util.Function found in modules androidx.arch.core.core-common-2.0.0.jar (androidx.arch.core.core-common-2.0.0.jar) and core-common-2.0.0.jar (androidx.arch.core:core-common:2.0.0)


    I've tried to delete androidx.core:core:1.1.0 but I can't find it anywhere, and also tried to delete resolved librairies in the external dependency manager but it didn't work.

    If I check to not load androidx.browser in the settings, the build works but no WebView is displayed in the app.

    It happens when I try to build with the UniWeb View asset.

    I've been on this issue for almost three days now and I really have no idea how to figure it out.
     
  2. Aurimas-Cernius

    Aurimas-Cernius

    Unity Technologies

    Joined:
    Jul 31, 2013
    Posts:
    3,732
    It seems that you use multiple libraries that have dependencies with incompatible versions.
    Can you show what libraries you use in gradle?
     
  3. Studio6D

    Studio6D

    Joined:
    Jun 10, 2021
    Posts:
    11
    Here are all the depencies from my mainTemplate.gradle file:


    dependencies {
    implementation fileTree(dir: 'libs', include: ['*.jar'])
    // Android Resolver Dependencies Start
    implementation 'com.applovin.mediation:unityads-adapter:3.7.2.0' // Assets/MaxSdk/Mediation/UnityAds/Editor/Dependencies.xml:4
    implementation 'com.applovin:applovin-sdk:10.3.1' // Assets/MaxSdk/AppLovin/Editor/Dependencies.xml:4
    implementation 'com.google.android.exoplayer:exoplayer:2.13.3' // Assets/MaxSdk/AppLovin/Editor/Dependencies.xml:6
    implementation 'com.google.android.gms:play-services-ads-identifier:16.0.0' // Assets/MaxSdk/AppLovin/Editor/Dependencies.xml:5
    // Android Resolver Dependencies End
    **DEPS**}
     
  4. Aurimas-Cernius

    Aurimas-Cernius

    Unity Technologies

    Joined:
    Jul 31, 2013
    Posts:
    3,732
    Better export Android Studio project to see the full list (including what possibly was added in place of DEPS).
    Then try commenting out dome of them to find conflicting ones.
     
  5. Demerzel_

    Demerzel_

    Joined:
    Mar 31, 2015
    Posts:
    4
    this must be the WORST build experience that any system has. android is so convoluted with crap, that it cannot realistically work.
    usually, I just target a higher min version that fixes these kind of errors. alternatively, dig through all your external plugins/sdks, see which one brings a random library (via the horrid gradle system that you really have no visibility into), and try to do some trial and error until you fix it
     
  6. DarxEagle

    DarxEagle

    Joined:
    Mar 11, 2014
    Posts:
    1
    I had the same problem and managed to resolve it in the following way:

    Initially, the custom templates in the project build settings were enabled. Specifically, android.useAndroidX=true and android.enableJetifier=true were added because some plugin required them.

    I disabled the custom templates, then made a build. During this process, Unity downloaded and resolved some libraries. I then re-enabled the custom templates and everything worked properly.
     
    Last edited: Apr 12, 2023