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.
The library using serialization could be found in the same repository. Here is how the dependency is configured.
Environment
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!
Having this issue as well on Gradle 6.6.1
I have this issue with Gradle 6.5 and 6.6.1
@SJOwl or @caiodev could you please provide a sample project with Gradle 6.6.1 that reproduces the issue?
@qwwdfsad Sure, if you clone this branch and try to build the project it will show you the error:
https://github.com/caiodev/GithubProfileSearcher/tree/implement_local_caching
@caiodev thanks!
@qwwdfsad Anytime 馃憤
@sandwwraith Do you have any ideas on when the next release will come out? Even if it's a RC? Thanks
@caiodev The 1.0.0-RC2 was released yesterday, please try it out, it should have this problem fixed
@sandwwraith Oh nice to hear that. I'm gonna test it. Thank you
@sandwwraith I wasn't able to test it since it's not been uploaded to maven(https://mvnrepository.com/artifact/org.jetbrains.kotlinx/kotlinx-serialization-runtime) yet. Could you let us know when this version makes its way to maven? Thank you
Am using new org.jetbrains.kotlinx:kotlinx-serialization-json:1.0.0-RC2 and gradle 6.1.1 and am still having this problem when trying to add kotlinx:kotlinx serialization to my project. Is it working for others ?
@mannyvw could you please provide a reproducing project?
@caiodev We've started the maven central sync a while ago, so RC2 may already be there. If it is not, try to include jcenter() to repositories
@sandwwraith Sure, I'll check it again and let you know. Thanks
@sandwwraith I don't know why but i still can't get this dependency resolved. I already had jcenter() on my gradle(project-level) file. Here's how it's setup:
repositories {
google()
jcenter()
mavenCentral()
}
allprojects {
repositories {
google()
jcenter()
mavenCentral()
}
}
That's the error message i get:
Failed to resolve: org.jetbrains.kotlinx:kotlinx-serialization-runtime:1.0.0-RC2
Show in Project Structure dialog
Affected Modules: app
I'll wait a little more and try again.
@mannyvw could you please provide a reproducing project?
seems to be clash with another library we are using com.algolia:algoliasearch-client-kotlin-android:1.3.1, if i knock that out or org.jetbrains.kotlinx:kotlinx-serialization-json:1.0.0-RC2 it builds ok
Well, actually changing from: org.jetbrains.kotlinx:kotlinx-serialization-runtime:1.0.0-RC2 to org.jetbrains.kotlinx:kotlinx-serialization-json:1.0.0-RC2 did the trick. Probably the runtime variant of it has been dropped and it's no longer gonna be maintained since it's not even on Maven yet. Fixed for me at least.
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
Environment:
1.4.1org.jetbrains.kotlinx:kotlinx-serialization-json:1.0.0-RC22.4.0 Error:
Duplicate class kotlinx.serialization.modules.SerializerAlreadyRegisteredException found in modules jetified-kotlinx-serialization-core-jvm-1.0.0-RC2.jar (org.jetbrains.kotlinx:kotlinx-serialization-core-jvm:1.0.0-RC2) and jetified-kotlinx-serialization-runtime-0.20.0.jar (org.jetbrains.kotlinx:kotlinx-serialization-runtime:0.20.0)
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:instantsearch dependencies, check this migration document.
It wasn't obvious, because the Android Studio did not initially highlighted that Algolia library needed upgrade.
Most helpful comment
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