kotlinx.serialization: Android project: 1.0.0RC - Need gradle 6.1.1, does not work with 5.6.4
Since upgrade from 0.20.0 to 1.0.0-RC along with Kotlin to 1.4.0 the application fails to build with multiple errors in ::sample:checkDebugDuplicateClasses task with messages like:
java.lang.RuntimeException:
Duplicate class kotlinx.serialization.AbstractSerialFormat found in modules
jetified-kotlinx-serialization-core-jvm-1.0.0-RC.jar (org.jetbrains.kotlinx:kotlinx-serialization-core-jvm:1.0.0-RC) and
jetified-kotlinx-serialization-core-jvm-1.0.0-RC.jar (org.jetbrains.kotlinx:kotlinx-serialization-core:1.0.0-RC)
It seems the problem is actual with gradle 5.6.4 and a workaround by upgrading to 6.1.1 fixes the problem. However this bump of major gradle version may not be that easy in many cases. Is it intended or is it a bug? The need for gradle upgrade is not mentioned in migration guide explicitly.
To Reproduce A sample application using the library with kotlinx.serialization dependency.
- include the library to see build failure. Commit
- Update gradle to 6.1.1 - build passes. Commit
The library using serialization could be found in the same repository. Here is how the dependency is configured.
Environment
- Kotlin version: 1.4.0
- Library version: 1.0.0-RC
- Kotlin platforms: JVM (Android)
- Gradle version: 5.6.4/6.1.1
- AGP 3.6.3
About this issue
- Original URL
- State: closed
- Created 4 years ago
- Reactions: 7
- Comments: 20 (7 by maintainers)
Commits related to this issue
- Rework publish-mpp-root-module-in-platform.gradle (#1020) * Don't duplicate the platform artifact in the root module * Instead of copying the platform POM to the root module, generate a new POM f... — committed to Kotlin/kotlinx.serialization by h0tk3y 4 years ago
- Rework publish-mpp-root-module-in-platform.gradle (#1020) * Don't duplicate the platform artifact in the root module * Instead of copying the platform POM to the root module, generate a new POM for... — committed to Kotlin/kotlinx.serialization by h0tk3y 4 years ago
For 1.0 release the maven coordinates were updated (along with many other parts of the api), so runtime no longer exists as a coordinate, but now is -core. -json provides the json format, but pulls in core transitively
I have this issue with Gradle 6.5 and 6.6.1
Thanks for bringing this to our attention! We were aware of issues with dependency resolution in Gradle < 6.0 that occur with the new publishing layout of kotlinx libraries, but we didn’t realize it could lead to duplicate artifacts in the resolution results and expected the issues to never affect any real-life project. I’m currently investigating this, and it seems that we could adjust the publishing layout to fix this in the future versions.
Also, it might be possible to workaround this issue by excluding some dependencies on the consumer side.
I’ll post the details in a while. Please stay tuned!
Environment:
1.4.1org.jetbrains.kotlinx:kotlinx-serialization-json:1.0.0-RC22.4.0Error:
Resolved:
1.4.1org.jetbrains.kotlinx:kotlinx-serialization-json:1.0.0-RC22.6.0<-- Bump this versionFor those having the same dependency issue, after upgrading to Kotlin 1.4.1, and who are using the
com.algolia:instantsearchdependencies, check this migration document. It wasn’t obvious, because the Android Studio did not initially highlighted that Algolia library needed upgrade.@caiodev The
1.0.0-RC2was released yesterday, please try it out, it should have this problem fixed@caiodev thanks!