Litote / kmongo

[deprecated] KMongo - a Kotlin toolkit for Mongo
https://litote.org/kmongo/
Apache License 2.0
781 stars 74 forks source link

ERROR: Invalid build configuration. Attempt to create a global synthetic for 'Record desugaring' without a global-synthetics consumer. #405

Closed NoodlesXNoodles closed 1 year ago

NoodlesXNoodles commented 1 year ago

Hello everyone,

I am facing a small issue, where executing kmongo code in a simple kt file with a main() function, it works fine, but when I try to implement it in my SDK project by installing it and adding "implementation 'org.litote.kmongo:kmongo:4.8.0'" to the build.gradle file, I consistently receive the following error during build: "Invalid build configuration. Attempt to create a global synthetic for 'Record desugaring' without a global-synthetics consumer." This error is definitely due to Kmongo, because if I remove the implementation, my application launches without error. I hope you can help me with this.

Thank you all.

zigzago commented 1 year ago

What is your version of kotlin ?

Frankat1578 commented 1 year ago

Hi, Am also experiencing the same issue in android studio kotlin project. When ever I add implementation("org.litote.kmongo:kmongo:4.8.0") to my dependency and run my kotlin project I get the same error(Invalid build configuration. Attempt to create a global synthetic for 'Record desugaring' without a global-synthetics consumer.) but when I remove this dependency and rerun the code the error does not appear again. My Kotlin version is = 213-1.7.20-release-for-android-studio-AS6777.52 What's Working Only the version4.5.0 works for me. The versions 4.6.0,4.7.0 and 4.8.0 are all not working.

NoodlesXNoodles commented 1 year ago

What's Working Only the version4.5.0 works for me. The versions 4.6.0,4.7.0 and 4.8.0 are all not working.

The same, but version 4.5 works perfectly

tfonrouge commented 1 year ago

Hi,

@NoodlesXNoodles , I think that you have to keep opened this issue because we haven't found yet the fix.

Doing a simple new Android project and including the current KMongo library:

implementation("org.litote.kmongo:kmongo:4.8.0")

throws the following error:

> Task :app:mergeExtDexDebug FAILED
AGPBI: {"kind":"error","text":"Invalid build configuration. Attempt to create a global synthetic for 'Record desugaring' without a global-synthetics consumer.","sources":[{}],"tool":"D8"}
...
> Task :app:mergeProjectDexDebug

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':app:mergeExtDexDebug'.
> Could not resolve all files for configuration ':app:debugRuntimeClasspath'.
   > Failed to transform bson-record-codec-4.8.0.jar (org.mongodb:bson-record-codec:4.8.0) to match attributes {artifactType=android-dex, asm-transformed-variant=NONE, dexing-enable-desugaring=true, dexing-enable-jacoco-instrumentation=false, dexing-is-debuggable=true, dexing-min-sdk=24, org.gradle.category=library, org.gradle.libraryelements=jar, org.gradle.status=release, org.gradle.usage=java-runtime}.
      > Execution failed for DexingNoClasspathTransform: /home/teo/.gradle/caches/modules-2/files-2.1/org.mongodb/bson-record-codec/4.8.0/5c4f81e2998a201466188c978642179f41dd3dfb/bson-record-codec-4.8.0.jar.
         > Error while dexing.

Seems to be that the culprit is the bson record codec in the mongodb library according to the above error.

I've tried to fix it including the desugar jdl library in the dependencies without success:

    coreLibraryDesugaring 'com.android.tools:desugar_jdk_libs:2.0.3'

HTH

best regards,

Teo