1

I have built an android library that I try to add in unity. Both the library and the unity project are very basic.

There are these 3 dependencies in the android project

implementation 'androidx.appcompat:appcompat:1.3.
implementation 'androidx.constraintlayout:constraintlayout:2.1.1'
implementation 'com.google.android.material:material:1.4.0

In the unity custom mainTemplate.graddle I replicated these dependencies because otherwise, the build was failing with missing classes errors (error: resource style/Theme.AppCompat.Light.NoActionBar (aka com.DefaultCompany.NewUnityProject:style/Theme.AppCompat.Light.NoActionBar) not found.).

I used the unity jar resolver to resolve dependencies in unity.

implementation fileTree(dir: 'libs', include: ['*.jar'])
// Android Resolver Dependencies Start
    implementation 'androidx.appcompat:appcompat:1.3.1' // Assets/ExternalDependencyManager/Editor/MyPluginDependencies.xml:3
    implementation 'androidx.constraintlayout:constraintlayout:2.1.1' // Assets/ExternalDependencyManager/Editor/MyPluginDependencies.xml:7
    implementation 'com.google.android.material:material:1.4.0' // Assets/ExternalDependencyManager/Editor/MyPluginDependencies.xml:11
// Android Resolver Dependencies End

The problem I've been facing now is that all these dependencies clash and there are over 1000 duplicate class errors like this one, from each of those 3 dependencies:

Duplicate class androidx.constraintlayout.widget.ConstraintAttribute$1 found in modules constraintlayout-2.1.1-runtime (androidx.constraintlayout:constraintlayout:2.1.1) and jetified-test-lib-release-runtime (:test-lib-release:) where test-lib-release is the android library.

I'm not sure what i am doing wrong and if it's because the library has these classes on the classpath or because my unity config is wrong. Any help is more than appreciated as i completely run out of ideas.

Popa Alex
  • 325
  • 2
  • 8

0 Answers0