googlesamples / googlesamples/unity-jar-resolver

[Bug] How to resolve colission on kotlin_module file dependencies

Open
#673 1 comment 0 reactions 0 assignees View on GitHub
type: question
Dominant language
C#
Stars
1.5k
Forks
371
Avg merge
14h 21m
Merged PRs (30d)
3

Description

### [REQUIRED] Please fill in the following fields:

* Unity editor version: 2021.3.3f1
* External Dependency Manager version: 1.2.176
* Source you installed EDM4U: .unitypackage
* Features in External Dependency Manager in use: Android Resolver
* Plugins SDK in use: Purchases (https://github.com/RevenueCat/purchases-unity) (RevenueCat)
* Platform you are using the Unity editor on: Mac

### [REQUIRED] Please describe the issue here:

Our Unity plugin has a dependency on an android only library (com.revenuecat.purchases:purchases) that has a dependency on `kotlinx-serialization-json`. Which itself has a compile dependency on `kotlinx-serialization-json-jvm`. This is in the pom file of `kotlinx-serialization-json`.

```

org.jetbrains.kotlinx
kotlinx-serialization-json-jvm
1.4.1
compile

```

The thing is that it looks like both `kotlinx-serialization-json-jvm` and `kotlinx-serialization-json` share the same name for their `kotlin_module`. So when using the regular Android resolver (no mainTemplate.gradle), users of my plugin get this issue:

```
* What went wrong:
Execution failed for task ':unityLibrary:mergeDebugJavaResource'.
> A failure occurred while executing com.android.build.gradle.internal.tasks.MergeJavaResWorkAction
> 2 files found with path 'META-INF/kotlinx-serialization-json.kotlin_module' from inputs:
```

I see both files:
- kotlinx-serialization-json-1.4.1.jar
- org.jetbrains.kotlinx.kotlinx-serialization-json-jvm-1.4.1.jar

I was wondering if there's something built in the plugin to prevent this. From now I've recommended using `mainTemplate.gradle` resolution to use standard Maven dependencies or adding:

```
packagingOptions {
resources.pickFirsts.add("META-INF/kotlinx-serialization-json.kotlin_module")
}
```

The fact that the dependency is `compile` in the pom also made me wonder if it is really necessary to download the .jar to compile the project. Isn't the `kotlinx-serialization-json-1.4.1.jar` already compiled code? Why do we need `org.jetbrains.kotlinx.kotlinx-serialization-json-jvm-1.4.1.jar`? This is probably me just misunderstanding how dependency resolution works in the context of Android development.

Thanks

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.