googlesamples / unity-jar-resolver

Unity plugin which resolves Android & iOS dependencies and performs version management
Other
1.21k stars 337 forks source link

[Question] Android resolver fails to resolve dependencies with minor/patch version differences. #576

Closed SpertsyanKM closed 1 year ago

SpertsyanKM commented 1 year ago

[REQUIRED] Please fill in the following fields:

[REQUIRED] Please describe the question here:

I've started receiving lots of conflicts after upgrading several Android dependencies in libraries that I use in my Unity project.

We have my.dependency.one:sdk:1.0.0 as an Android dependency described in xml-file, which in turn contains my.dependency.two:sdk:4.0.0 as a dependency. Both of them have several other libraries as dependencies. Now when I try to resolve dependencies in my unity project, I see a lot of conflicts as below.

My question is - why the resolver can't handle such conflicts by picking the highest required version? Like androidx.activity:activity:1.5.1 in the current example.

Also, there are some conflicts, which use exactly the same version of the dependency. See the second example.

What can I do to handle these problems? The whole process takes 20+ attempts to find the proper dependency versions and finally fails with an unexpected error in one of the nested dependencies.

Resolution attempt 1: packages [com.fasterxml.jackson.core:jackson-databind:2.11.1, my.dependency.one:sdk:1.0.0, org.jetbrains.kotlin:kotlin-stdlib-jdk8:1.3.61]
androidx.activity:activity conflicting due to package(s):
- my.dependency.one:sdk:1.0.0/androidx.preference:preference:1.2.0/androidx.appcompat:appcompat:1.1.0/androidx.activity:activity:1.5.1
- my.dependency.one:sdk:1.0.0/androidx.preference:preference:1.2.0/androidx.appcompat:appcompat:1.1.0/androidx.fragment:fragment:1.3.6/androidx.activity:activity:1.2.4
- my.dependency.one:sdk:1.0.0/androidx.preference:preference:1.2.0/androidx.fragment:fragment-ktx:1.3.6/androidx.activity:activity-ktx:1.2.2/androidx.activity:activity:[1.2.2]
- my.dependency.one:sdk:1.0.0/androidx.preference:preference:1.2.0/androidx.fragment:fragment-ktx:1.3.6/androidx.fragment:fragment:[1.3.6]/androidx.activity:activity:1.2.4
- my.dependency.one:sdk:1.0.0/my.dependency.two:sdk:4.0.0/androidx.appcompat:appcompat:1.5.1/androidx.activity:activity:1.5.1
- my.dependency.one:sdk:1.0.0/my.dependency.two:sdk:4.0.0/androidx.appcompat:appcompat:1.5.1/androidx.fragment:fragment:1.3.6/androidx.activity:activity:1.2.4
- my.dependency.one:sdk:1.0.0/my.dependency.two:sdk:4.0.0/androidx.constraintlayout:constraintlayout:2.1.4/androidx.appcompat:appcompat:1.2.0/androidx.activity:activity:1.5.1
androidx.fragment:fragment conflicting due to package(s):
- my.dependency.one:sdk:1.0.0/androidx.preference:preference:1.2.0/androidx.appcompat:appcompat:1.1.0/androidx.fragment:fragment:1.3.6
- my.dependency.one:sdk:1.0.0/androidx.preference:preference:1.2.0/androidx.fragment:fragment-ktx:1.3.6/androidx.fragment:fragment:[1.3.6]
- my.dependency.one:sdk:1.0.0/my.dependency.two:sdk:4.0.0/androidx.appcompat:appcompat:1.5.1/androidx.fragment:fragment:1.3.6
- my.dependency.one:sdk:1.0.0/my.dependency.two:sdk:4.0.0/androidx.constraintlayout:constraintlayout:2.1.4/androidx.appcompat:appcompat:1.2.0/androidx.fragment:fragment:1.3.6
- my.dependency.one:sdk:1.0.0/my.dependency.two:sdk:4.0.0/androidx.preference:preference:1.2.0/androidx.appcompat:appcompat:1.1.0/androidx.fragment:fragment:1.3.6
- my.dependency.one:sdk:1.0.0/my.dependency.two:sdk:4.0.0/androidx.preference:preference:1.2.0/androidx.fragment:fragment-ktx:1.3.6/androidx.fragment:fragment:[1.3.6]
androidx.fragment:fragment-ktx conflicting due to package(s):
- my.dependency.one:sdk:1.0.0/androidx.preference:preference:1.2.0/androidx.fragment:fragment-ktx:1.3.6
- my.dependency.one:sdk:1.0.0/my.dependency.two:sdk:4.0.0/androidx.preference:preference:1.2.0/androidx.fragment:fragment-ktx:1.3.6
google-oss-bot commented 1 year ago

This issue does not seem to follow the issue template. Make sure you provide all the required information.

paulinon commented 1 year ago

Hi @SpertsyanKM,

Could you try these steps to see if they make a difference? Make sure both Custom Main Gradle Template and Custom Gradle Properties Template under Player Settings are enabled when doing so.

If the issue persists, please provide a minimal, reproducible example of your implementation so that we can identify what's causing this.

SpertsyanKM commented 1 year ago

Hi!

I've tried this, but then resolving finishes successfully in a second, but the build then fails with the same error, which caused resolution failure in my original example. It seems, like it tries to build with the dependencies from the last resolution attempt, and still fails.

Maybe it is the core problem. Let me try to solve that error first, maybe in addition to your advice, it will help me. I'll return as soon as I have any info.

SpertsyanKM commented 1 year ago

Well, seems like the problem was somewhere between Android Gradle Plugin and Kotlin version upgrades. I've downgraded my.dependency.one:sdk and my.dependency.two:sdk nested dependencies, as well as their Kotlin and AGP versions, and resolving began working again, but the following errors began occurring while building. If resolving without custom gradle templates. While I continue investigating, tell me please, can it be the problem of the resolver?

* What went wrong:
Execution failed for task ':launcher:checkDebugDuplicateClasses'.
> 1 exception was raised by workers:
  java.lang.RuntimeException: Duplicate class android.support.v4.app.INotificationSideChannel found in modules androidx.core.core-1.3.1-runtime.jar (:androidx.core.core-1.3.1:) and androidx.core.core-1.9.0-runtime.jar (:androidx.core.core-1.9.0:)
  Duplicate class android.support.v4.app.INotificationSideChannel$Default found in modules androidx.core.core-1.3.1-runtime.jar (:androidx.core.core-1.3.1:) and androidx.core.core-1.9.0-runtime.jar (:androidx.core.core-1.9.0:)
  Duplicate class android.support.v4.app.INotificationSideChannel$Stub found in modules androidx.core.core-1.3.1-runtime.jar (:androidx.core.core-1.3.1:) and androidx.core.core-1.9.0-runtime.jar (:androidx.core.core-1.9.0:)
  Duplicate class android.support.v4.app.INotificationSideChannel$Stub$Proxy found in modules androidx.core.core-1.3.1-runtime.jar (:androidx.core.core-1.3.1:) and androidx.core.core-1.9.0-runtime.jar (:androidx.core.core-1.9.0:)
  Duplicate class android.support.v4.app.RemoteActionCompatParcelizer found in modules androidx.core.core-1.3.1-runtime.jar (:androidx.core.core-1.3.1:) and androidx.core.core-1.9.0-runtime.jar (:androidx.core.core-1.9.0:)
  Duplicate class android.support.v4.graphics.drawable.IconCompatParcelizer found in modules androidx.core.core-1.3.1-runtime.jar (:androidx.core.core-1.3.1:) and androidx.core.core-1.9.0-runtime.jar (:androidx.core.core-1.9.0:)
  Duplicate class android.support.v4.os.IResultReceiver found in modules androidx.core.core-1.3.1-runtime.jar (:androidx.core.core-1.3.1:) and androidx.core.core-1.9.0-runtime.jar (:androidx.core.core-1.9.0:)
  Duplicate class android.support.v4.os.IResultReceiver$Default found in modules androidx.core.core-1.3.1-runtime.jar (:androidx.core.core-1.3.1:) and androidx.core.core-1.9.0-runtime.jar (:androidx.core.core-1.9.0:)
  Duplicate class android.support.v4.os.IResultReceiver$Stub found in modules androidx.core.core-1.3.1-runtime.jar (:androidx.core.core-1.3.1:) and androidx.core.core-1.9.0-runtime.jar (:androidx.core.core-1.9.0:)
  Duplicate class android.support.v4.os.IResultReceiver$Stub$Proxy found in modules androidx.core.core-1.3.1-runtime.jar (:androidx.core.core-1.3.1:) and androidx.core.core-1.9.0-runtime.jar (:androidx.core.core-1.9.0:)
  Duplicate class android.support.v4.os.ResultReceiver found in modules androidx.core.core-1.3.1-runtime.jar (:androidx.core.core-1.3.1:) and androidx.core.core-1.9.0-runtime.jar (:androidx.core.core-1.9.0:)
  Duplicate class android.support.v4.os.ResultReceiver$1 found in modules androidx.core.core-1.3.1-runtime.jar (:androidx.core.core-1.3.1:) and androidx.core.core-1.9.0-runtime.jar (:androidx.core.core-1.9.0:)
  Duplicate class android.support.v4.os.ResultReceiver$MyResultReceiver found in modules androidx.core.core-1.3.1-runtime.jar (:androidx.core.core-1.3.1:) and androidx.core.core-1.9.0-runtime.jar (:androidx.core.core-1.9.0:)
  Duplicate class android.support.v4.os.ResultReceiver$MyRunnable found in modules androidx.core.core-1.3.1-runtime.jar (:androidx.core.core-1.3.1:) and androidx.core.core-1.9.0-runtime.jar (:androidx.core.core-1.9.0:)
  Duplicate class androidx.activity.Cancellable found in modules androidx.activity.activity-1.1.0-runtime.jar (:androidx.activity.activity-1.1.0:) and androidx.activity.activity-1.7.0-alpha02-runtime.jar (:androidx.activity.activity-1.7.0-alpha02:)
  Duplicate class androidx.activity.ComponentActivity found in modules androidx.activity.activity-1.1.0-runtime.jar (:androidx.activity.activity-1.1.0:) and androidx.activity.activity-1.7.0-alpha02-runtime.jar (:androidx.activity.activity-1.7.0-alpha02:)
  Duplicate class androidx.activity.ComponentActivity$1 found in modules androidx.activity.activity-1.1.0-runtime.jar (:androidx.activity.activity-1.1.0:) and androidx.activity.activity-1.7.0-alpha02-runtime.jar (:androidx.activity.activity-1.7.0-alpha02:)
  Duplicate class androidx.activity.ComponentActivity$2 found in modules androidx.activity.activity-1.1.0-runtime.jar (:androidx.activity.activity-1.1.0:) and androidx.activity.activity-1.7.0-alpha02-runtime.jar (:androidx.activity.activity-1.7.0-alpha02:)
  Duplicate class androidx.activity.ComponentActivity$3 found in modules androidx.activity.activity-1.1.0-runtime.jar (:androidx.activity.activity-1.1.0:) and androidx.activity.activity-1.7.0-alpha02-runtime.jar (:androidx.activity.activity-1.7.0-alpha02:)
  Duplicate class androidx.activity.ComponentActivity$NonConfigurationInstances found in modules androidx.activity.activity-1.1.0-runtime.jar (:androidx.activity.activity-1.1.0:) and androidx.activity.activity-1.7.0-alpha02-runtime.jar (:androidx.activity.activity-1.7.0-alpha02:)
  Duplicate class androidx.activity.ImmLeaksCleaner found in modules androidx.activity.activity-1.1.0-runtime.jar (:androidx.activity.activity-1.1.0:) and androidx.activity.activity-1.7.0-alpha02-runtime.jar (:androidx.activity.activity-1.7.0-alpha02:)
  Duplicate class androidx.activity.OnBackPressedCallback found in modules androidx.activity.activity-1.1.0-runtime.jar (:androidx.activity.activity-1.1.0:) and androidx.activity.activity-1.7.0-alpha02-runtime.jar (:androidx.activity.activity-1.7.0-alpha02:)
  Duplicate class androidx.activity.OnBackPressedDispatcher found in modules androidx.activity.activity-1.1.0-runtime.jar (:androidx.activity.activity-1.1.0:) and androidx.activity.activity-1.7.0-alpha02-runtime.jar (:androidx.activity.activity-1.7.0-alpha02:)
  Duplicate class androidx.activity.OnBackPressedDispatcher$LifecycleOnBackPressedCancellable found in modules androidx.activity.activity-1.1.0-runtime.jar (:androidx.activity.activity-1.1.0:) and androidx.activity.activity-1.7.0-alpha02-runtime.jar (:androidx.activity.activity-1.7.0-alpha02:)
  Duplicate class androidx.activity.OnBackPressedDispatcher$OnBackPressedCancellable found in modules androidx.activity.activity-1.1.0-runtime.jar (:androidx.activity.activity-1.1.0:) and androidx.activity.activity-1.7.0-alpha02-runtime.jar (:androidx.activity.activity-1.7.0-alpha02:)
  Duplicate class androidx.activity.OnBackPressedDispatcherOwner found in modules androidx.activity.activity-1.1.0-runtime.jar (:androidx.activity.activity-1.1.0:) and androidx.activity.activity-1.7.0-alpha02-runtime.jar (:androidx.activity.activity-1.7.0-alpha02:)
  Duplicate class androidx.annotation.AnimRes found in modules androidx.annotation.annotation-1.1.0.jar (androidx.annotation.annotation-1.1.0.jar) and androidx.annotation.annotation-1.3.0.jar (androidx.annotation.annotation-1.3.0.jar)
  Duplicate class androidx.annotation.AnimatorRes found in modules androidx.annotation.annotation-1.1.0.jar (androidx.annotation.annotation-1.1.0.jar) and androidx.annotation.annotation-1.3.0.jar (androidx.annotation.annotation-1.3.0.jar)
  Duplicate class androidx.annotation.AnyRes found in modules androidx.annotation.annotation-1.1.0.jar (androidx.annotation.annotation-1.1.0.jar) and androidx.annotation.annotation-1.3.0.jar (androidx.annotation.annotation-1.3.0.jar)
  Duplicate class androidx.annotation.AnyThread found in modules androidx.annotation.annotation-1.1.0.jar (androidx.annotation.annotation-1.1.0.jar) and androidx.annotation.annotation-1.3.0.jar (androidx.annotation.annotation-1.3.0.jar)
  Duplicate class androidx.annotation.ArrayRes found in modules androidx.annotation.annotation-1.1.0.jar (androidx.annotation.annotation-1.1.0.jar) and androidx.annotation.annotation-1.3.0.jar (androidx.annotation.annotation-1.3.0.jar)
  Duplicate class androidx.annotation.AttrRes found in modules androidx.annotation.annotation-1.1.0.jar (androidx.annotation.annotation-1.1.0.jar) and androidx.annotation.annotation-1.3.0.jar (androidx.annotation.annotation-1.3.0.jar)
  Duplicate class androidx.annotation.BinderThread found in modules androidx.annotation.annotation-1.1.0.jar (androidx.annotation.annotation-1.1.0.jar) and androidx.annotation.annotation-1.3.0.jar (androidx.annotation.annotation-1.3.0.jar)
  Duplicate class androidx.annotation.BoolRes found in modules androidx.annotation.annotation-1.1.0.jar (androidx.annotation.annotation-1.1.0.jar) and androidx.annotation.annotation-1.3.0.jar (androidx.annotation.annotation-1.3.0.jar)
  Duplicate class androidx.annotation.CallSuper found in modules androidx.annotation.annotation-1.1.0.jar (androidx.annotation.annotation-1.1.0.jar) and androidx.annotation.annotation-1.3.0.jar (androidx.annotation.annotation-1.3.0.jar)
  Duplicate class androidx.annotation.CheckResult found in modules androidx.annotation.annotation-1.1.0.jar (androidx.annotation.annotation-1.1.0.jar) and androidx.annotation.annotation-1.3.0.jar (androidx.annotation.annotation-1.3.0.jar)
  Duplicate class androidx.annotation.ColorInt found in modules androidx.annotation.annotation-1.1.0.jar (androidx.annotation.annotation-1.1.0.jar) and androidx.annotation.annotation-1.3.0.jar (androidx.annotation.annotation-1.3.0.jar)
  Duplicate class androidx.annotation.ColorLong found in modules androidx.annotation.annotation-1.1.0.jar (androidx.annotation.annotation-1.1.0.jar) and androidx.annotation.annotation-1.3.0.jar (androidx.annotation.annotation-1.3.0.jar)
  Duplicate class androidx.annotation.ColorRes found in modules androidx.annotation.annotation-1.1.0.jar (androidx.annotation.annotation-1.1.0.jar) and androidx.annotation.annotation-1.3.0.jar (androidx.annotation.annotation-1.3.0.jar)
  Duplicate class androidx.annotation.ContentView found in modules androidx.annotation.annotation-1.1.0.jar (androidx.annotation.annotation-1.1.0.jar) and androidx.annotation.annotation-1.3.0.jar (androidx.annotation.annotation-1.3.0.jar)
  Duplicate class androidx.annotation.DimenRes found in modules androidx.annotation.annotation-1.1.0.jar (androidx.annotation.annotation-1.1.0.jar) and androidx.annotation.annotation-1.3.0.jar (androidx.annotation.annotation-1.3.0.jar)
  Duplicate class androidx.annotation.Dimension found in modules androidx.annotation.annotation-1.1.0.jar (androidx.annotation.annotation-1.1.0.jar) and androidx.annotation.annotation-1.3.0.jar (androidx.annotation.annotation-1.3.0.jar)
  Duplicate class androidx.annotation.DrawableRes found in modules androidx.annotation.annotation-1.1.0.jar (androidx.annotation.annotation-1.1.0.jar) and androidx.annotation.annotation-1.3.0.jar (androidx.annotation.annotation-1.3.0.jar)
  Duplicate class androidx.annotation.FloatRange found in modules androidx.annotation.annotation-1.1.0.jar (androidx.annotation.annotation-1.1.0.jar) and androidx.annotation.annotation-1.3.0.jar (androidx.annotation.annotation-1.3.0.jar)
  Duplicate class androidx.annotation.FontRes found in modules androidx.annotation.annotation-1.1.0.jar (androidx.annotation.annotation-1.1.0.jar) and androidx.annotation.annotation-1.3.0.jar (androidx.annotation.annotation-1.3.0.jar)
  Duplicate class androidx.annotation.FractionRes found in modules androidx.annotation.annotation-1.1.0.jar (androidx.annotation.annotation-1.1.0.jar) and androidx.annotation.annotation-1.3.0.jar (androidx.annotation.annotation-1.3.0.jar)
  Duplicate class androidx.annotation.GuardedBy found in modules androidx.annotation.annotation-1.1.0.jar (androidx.annotation.annotation-1.1.0.jar) and androidx.annotation.annotation-1.3.0.jar (androidx.annotation.annotation-1.3.0.jar)
  Duplicate class androidx.annotation.HalfFloat found in modules androidx.annotation.annotation-1.1.0.jar (androidx.annotation.annotation-1.1.0.jar) and androidx.annotation.annotation-1.3.0.jar (androidx.annotation.annotation-1.3.0.jar)
  Duplicate class androidx.annotation.IdRes found in modules androidx.annotation.annotation-1.1.0.jar (androidx.annotation.annotation-1.1.0.jar) and androidx.annotation.annotation-1.3.0.jar (androidx.annotation.annotation-1.3.0.jar)
  Duplicate class androidx.annotation.InspectableProperty found in modules androidx.annotation.annotation-1.1.0.jar (androidx.annotation.annotation-1.1.0.jar) and androidx.annotation.annotation-1.3.0.jar (androidx.annotation.annotation-1.3.0.jar)
  Duplicate class androidx.annotation.InspectableProperty$EnumEntry found in modules androidx.annotation.annotation-1.1.0.jar (androidx.annotation.annotation-1.1.0.jar) and androidx.annotation.annotation-1.3.0.jar (androidx.annotation.annotation-1.3.0.jar)
  Duplicate class androidx.annotation.InspectableProperty$FlagEntry found in modules androidx.annotation.annotation-1.1.0.jar (androidx.annotation.annotation-1.1.0.jar) and androidx.annotation.annotation-1.3.0.jar (androidx.annotation.annotation-1.3.0.jar)
  Duplicate class androidx.annotation.InspectableProperty$ValueType found in modules androidx.annotation.annotation-1.1.0.jar (androidx.annotation.annotation-1.1.0.jar) and androidx.annotation.annotation-1.3.0.jar (androidx.annotation.annotation-1.3.0.jar)
  Duplicate class androidx.annotation.IntDef found in modules androidx.annotation.annotation-1.1.0.jar (androidx.annotation.annotation-1.1.0.jar) and androidx.annotation.annotation-1.3.0.jar (androidx.annotation.annotation-1.3.0.jar)
  Duplicate class androidx.annotation.IntRange found in modules androidx.annotation.annotation-1.1.0.jar (androidx.annotation.annotation-1.1.0.jar) and androidx.annotation.annotation-1.3.0.jar (androidx.annotation.annotation-1.3.0.jar)
  Duplicate class androidx.annotation.IntegerRes found in modules androidx.annotation.annotation-1.1.0.jar (androidx.annotation.annotation-1.1.0.jar) and androidx.annotation.annotation-1.3.0.jar (androidx.annotation.annotation-1.3.0.jar)
  Duplicate class androidx.annotation.InterpolatorRes found in modules androidx.annotation.annotation-1.1.0.jar (androidx.annotation.annotation-1.1.0.jar) and androidx.annotation.annotation-1.3.0.jar (androidx.annotation.annotation-1.3.0.jar)
  Duplicate class androidx.annotation.Keep found in modules androidx.annotation.annotation-1.1.0.jar (androidx.annotation.annotation-1.1.0.jar) and androidx.annotation.annotation-1.3.0.jar (androidx.annotation.annotation-1.3.0.jar)
  Duplicate class androidx.annotation.LayoutRes found in modules androidx.annotation.annotation-1.1.0.jar (androidx.annotation.annotation-1.1.0.jar) and androidx.annotation.annotation-1.3.0.jar (androidx.annotation.annotation-1.3.0.jar)
  Duplicate class androidx.annotation.LongDef found in modules androidx.annotation.annotation-1.1.0.jar (androidx.annotation.annotation-1.1.0.jar) and androidx.annotation.annotation-1.3.0.jar (androidx.annotation.annotation-1.3.0.jar)
  Duplicate class androidx.annotation.MainThread found in modules androidx.annotation.annotation-1.1.0.jar (androidx.annotation.annotation-1.1.0.jar) and androidx.annotation.annotation-1.3.0.jar (androidx.annotation.annotation-1.3.0.jar)
  Duplicate class androidx.annotation.MenuRes found in modules androidx.annotation.annotation-1.1.0.jar (androidx.annotation.annotation-1.1.0.jar) and androidx.annotation.annotation-1.3.0.jar (androidx.annotation.annotation-1.3.0.jar)
  Duplicate class androidx.annotation.NavigationRes found in modules androidx.annotation.annotation-1.1.0.jar (androidx.annotation.annotation-1.1.0.jar) and androidx.annotation.annotation-1.3.0.jar (androidx.annotation.annotation-1.3.0.jar)
  Duplicate class androidx.annotation.NonNull found in modules androidx.annotation.annotation-1.1.0.jar (androidx.annotation.annotation-1.1.0.jar) and androidx.annotation.annotation-1.3.0.jar (androidx.annotation.annotation-1.3.0.jar)
  Duplicate class androidx.annotation.Nullable found in modules androidx.annotation.annotation-1.1.0.jar (androidx.annotation.annotation-1.1.0.jar) and androidx.annotation.annotation-1.3.0.jar (androidx.annotation.annotation-1.3.0.jar)
  Duplicate class androidx.annotation.PluralsRes found in modules androidx.annotation.annotation-1.1.<message truncated>
SpertsyanKM commented 1 year ago

Looks like for some reason resolver includes several versions of dependencies instead of choosing the newest one. There are really multiple version aars for several dependencies In Assets/Plugins/Android.

When resolving with custom gradle templates, the dependency aars are correct - one version per dependency, but another compile-time problem occurs -

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':launcher:mergeDebugJavaResource'.
> A failure occurred while executing com.android.build.gradle.internal.tasks.Workers$ActionFacade
   > More than one file was found with OS independent path 'META-INF/androidx.preference_preference.version'.

Continuing investigation...

chkuang-g commented 1 year ago

Hi @SpertsyanKM,

 Duplicate class android.support.v4.app.INotificationSideChannel$Default found in modules androidx.core.core-1.3.1-runtime.jar (:androidx.core.core-1.3.1:) and androidx.core.core-1.9.0-runtime.jar (:androidx.core.core-1.9.0:)

This is a sign when the legacy Android support libraries conflict with AndroidX support libraries. And the solution is to enable Jetifier.

Could you try to enable Jetifier under Assets > External Dependency Manager > Android Resolver > Settings? Also, if you enabled maintemplate.gradle, please also enable Custom Gradle Properties Template as well.

Once these are done, try to do Assets > External Dependency Manager > Android Resolver > Force Resolve again and see if you can find Jetifier enabled in Assets/Plugins/Android/gradleTemplate.properties.

If so, try to build again.

SpertsyanKM commented 1 year ago

I've tried both cases. And both fail with the following errors:

Duplicate class android.support.v4.app.RemoteActionCompatParcelizer found in modules core-1.3.1-runtime.jar (androidx.core:core:1.3.1) and jetified-androidx.core.core-1.9.0-runtime.jar (:androidx.core.core-1.9.0:)
  Duplicate class android.support.v4.graphics.drawable.IconCompatParcelizer found in modules core-1.3.1-runtime.jar (androidx.core:core:1.3.1) and jetified-androidx.core.core-1.9.0-runtime.jar (:androidx.core.core-1.9.0:)
  Duplicate class android.support.v4.os.ResultReceiver found in modules core-1.3.1-runtime.jar (androidx.core:core:1.3.1) and jetified-androidx.core.core-1.9.0-runtime.jar (:androidx.core.core-1.9.0:)
  Duplicate class android.support.v4.os.ResultReceiver$1 found in modules core-1.3.1-runtime.jar (androidx.core:core:1.3.1) and jetified-androidx.core.core-1.9.0-runtime.jar (:androidx.core.core-1.9.0:)
  Duplicate class android.support.v4.os.ResultReceiver$MyResultReceiver found in modules core-1.3.1-runtime.jar (androidx.core:core:1.3.1) and jetified-androidx.core.core-1.9.0-runtime.jar (:androidx.core.core-1.9.0:)
  Duplicate class android.support.v4.os.ResultReceiver$MyRunnable found in modules core-1.3.1-runtime.jar (androidx.core:core:1.3.1) and jetified-androidx.core.core-1.9.0-runtime.jar (:androidx.core.core-1.9.0:)
  Duplicate class androidx.activity.Cancellable found in modules jetified-activity-1.1.0-runtime.jar (androidx.activity:activity:1.1.0) and jetified-androidx.activity.activity-1.7.0-alpha02-runtime.jar (:androidx.activity.activity-1.7.0-alpha02:)
  Duplicate class androidx.activity.ComponentActivity found in modules jetified-activity-1.1.0-runtime.jar (androidx.activity:activity:1.1.0) and jetified-androidx.activity.activity-1.7.0-alpha02-runtime.jar (:androidx.activity.activity-1.7.0-alpha02:)
  Duplicate class androidx.activity.ComponentActivity$1 found in modules jetified-activity-1.1.0-runtime.jar (androidx.activity:activity:1.1.0) and jetified-androidx.activity.activity-1.7.0-alpha02-runtime.jar (:androidx.activity.activity-1.7.0-alpha02:)
  Duplicate class androidx.activity.ComponentActivity$2 found in modules jetified-activity-1.1.0-runtime.jar (androidx.activity:activity:1.1.0) and jetified-androidx.activity.activity-1.7.0-alpha02-runtime.jar (:androidx.activity.activity-1.7.0-alpha02:)
  Duplicate class androidx.activity.ComponentActivity$3 found in modules jetified-activity-1.1.0-runtime.jar (androidx.activity:activity:1.1.0) and jetified-androidx.activity.activity-1.7.0-alpha02-runtime.jar (:androidx.activity.activity-1.7.0-alpha02:)

and so on.

If I disable custom gradle templates (but still leave Jetifier enabled in resolver settings), the final build for some reasons doesn't have the following options in gradle.properties.

android.useAndroidX=true
android.enableJetifier=true

After adding these lines, build fails with the above errors.

When custom gradle templates are enabled, these lines exist, but build also fails with the above errors.

Also, there are several errors of this kind for some reason, so I needed to add exclude options for the mentioned files in packagingOptions of gradle file. These errors do not seem to be related to resolver, but who knows..

        exclude 'META-INF/androidx.preference_preference.version'
        exclude 'META-INF/androidx.lifecycle_lifecycle-livedata-core.version'
        exclude 'META-INF/androidx.lifecycle_lifecycle-viewmodel-savedstate.version'
        exclude 'META-INF/androidx.appcompat_appcompat.version'
SpertsyanKM commented 1 year ago

Finally I was able to build the app after creating new unity project and adding the dependencies from scratch. I can't explain, what is the problem with the original project, but at least I'm not blocked now.

DellaBitta commented 1 year ago

Hi @SpertsyanKM that's great to hear! If you run into a problem again then please open and issue with more information. If it's similar to this issue then please link this one.

Thanks so much!