Skip to content

Dependency requires core library desugaring to be enabled #610

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
Monabr opened this issue Sep 1, 2024 · 15 comments · Fixed by #618
Closed

Dependency requires core library desugaring to be enabled #610

Monabr opened this issue Sep 1, 2024 · 15 comments · Fixed by #618

Comments

@Monabr
Copy link

Monabr commented Sep 1, 2024

Dependency 'dev.gitlive:firebase-config-android-debug:2.0.0' requires core library desugaring to be enabled
           for :shared.

I believe this should be fixed.

@Reedyuk
Copy link
Collaborator

Reedyuk commented Sep 2, 2024

Can you post your build gradle, sounds like you might be adding the dependancy incorrectly.

@Monabr
Copy link
Author

Monabr commented Sep 2, 2024

@Reedyuk I believe nothing special here

sourceSets {
   ...
   commonMain.dependencies {
      implementation("dev.gitlive:firebase-analytics:2.0.0")
      implementation("dev.gitlive:firebase-auth:2.0.0")
      implementation("dev.gitlive:firebase-database:2.0.0")
      implementation("dev.gitlive:firebase-firestore:2.0.0")
      implementation("dev.gitlive:firebase-functions:2.0.0")
      implementation("dev.gitlive:firebase-messaging:2.0.0")
      implementation("dev.gitlive:firebase-storage:2.0.0")
      implementation("dev.gitlive:firebase-installations:2.0.0")
      implementation("dev.gitlive:firebase-config:2.0.0")
      implementation("dev.gitlive:firebase-perf:2.0.0")
      implementation("dev.gitlive:firebase-crashlytics:2.0.0")
   }
   ...
}

@Reedyuk
Copy link
Collaborator

Reedyuk commented Sep 2, 2024

What version of the JDK are you targeting? just wondering if its an issue with an older version being used?

@Monabr
Copy link
Author

Monabr commented Sep 2, 2024

@Reedyuk

androidTarget {
        compilations.all {
            kotlinOptions {
                jvmTarget = "17"
                freeCompilerArgs = listOf(
                    "-opt-in=kotlinx.serialization.ExperimentalSerializationApi",
                    "-Xno-param-assertions",
                    "-Xno-call-assertions",
                    "-Xno-receiver-assertions",
                    "-Xexpect-actual-classes"
                )
            }
        }
    }
    
    
    android {
       compileOptions {
        isCoreLibraryDesugaringEnabled = true <--- added with your liblary

        sourceCompatibility = JavaVersion.VERSION_17
        targetCompatibility = JavaVersion.VERSION_17
      }
    }

@Reedyuk
Copy link
Collaborator

Reedyuk commented Sep 2, 2024

Just for reference, when you enable this property, does your project work?
Sorry, i have not come across this issue before, so its interested to see.
I think this only affects users who are using Android Build tools 4.x.x
I have been using 7.x.x and never came across this.

@Monabr
Copy link
Author

Monabr commented Sep 2, 2024

@Reedyuk I don't really know for now. Currently I am writing implementations for IOS of my common classes. But without isCoreLibraryDesugaringEnabled gradle did not sync.

My gradle version: 8.5.2

@Reedyuk
Copy link
Collaborator

Reedyuk commented Sep 2, 2024

gradle is fine, my guess is you have this somewhere:

com.android.tools.build:gradle:4.x.x

And this is version 4.x.x

You highlight that maybe what we need is an example KMP(with compose) that uses the library.

@Monabr
Copy link
Author

Monabr commented Sep 2, 2024

@Reedyuk After searching I see that I don't use com.android.tools.build.

I have:
com.android.application
com.android.library
with gradle version if we are talking about android plugins.

@Reedyuk
Copy link
Collaborator

Reedyuk commented Sep 2, 2024

Whats your min android version you are targeting?

@Reedyuk
Copy link
Collaborator

Reedyuk commented Sep 2, 2024

This seems to shed some light:
https://medium.com/androiddevelopers/support-for-newer-java-language-apis-bca79fc8ef65
Looks to me like its more related to android than it is this project. I would imagine you would have to add that property for any other libs.

@Monabr
Copy link
Author

Monabr commented Sep 2, 2024

You highlight that maybe what we need is an example KMP(with compose) that uses the library.

@Reedyuk I have reproduce example:

  1. Create project from JetBrains KMP template https://kmp.jetbrains.com/
  2. Add dependencies that I posted above
  3. Run ./gradlew assembleDebug

Project will not build and throw the error I posted.

Whats your min android version you are targeting?
Looks to me like its more related to android than it is this project. I would imagine you would have to add that property for any other libs.

I have way over 21 min sdk

minSdk = 28
targetSdk = 35

@Reedyuk
Copy link
Collaborator

Reedyuk commented Sep 2, 2024

ok thanks for the report

@Daeda88
Copy link
Contributor

Daeda88 commented Sep 2, 2024

Desugaring is required for the config module as of #553 @Reedyuk and @Monabr due to the use of Kotlinx datetime which requires it as well. Only core library desugaring is required https://github.com/Kotlin/kotlinx-datetime?tab=readme-ov-file#using-in-your-projects

@Monabr
Copy link
Author

Monabr commented Sep 2, 2024

Desugaring is required for the config module as of #553 @Reedyuk and @Monabr due to the use of Kotlinx datetime which requires it as well. Only core library desugaring is required https://github.com/Kotlin/kotlinx-datetime?tab=readme-ov-file#using-in-your-projects

According to the docs If you target Android devices running below API 26 we need desugaring. And according to this web-site https://apilevels.com/ API 26 is 95.5% of users.

I believe you can safely update minSdk to 26.

@Daeda88
Copy link
Contributor

Daeda88 commented Sep 3, 2024

Did some digging around and it seems fine to just disable core library desugaring on the module itself. Should only be added on the app implementing the SDK. See #618

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants