GitLiveApp / firebase-kotlin-sdk

A Kotlin-first SDK for Firebase
https://gitliveapp.github.io/firebase-kotlin-sdk/
Apache License 2.0
1.17k stars 155 forks source link

Dependency requires core library desugaring to be enabled #610

Closed Monabr closed 2 months ago

Monabr commented 2 months ago
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 commented 2 months ago

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

Monabr commented 2 months ago

@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 commented 2 months ago

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

Monabr commented 2 months ago

@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 commented 2 months ago

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 commented 2 months ago

@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 commented 2 months ago

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 commented 2 months ago

@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 commented 2 months ago

Whats your min android version you are targeting?

Reedyuk commented 2 months ago

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 commented 2 months ago

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 commented 2 months ago

ok thanks for the report

Daeda88 commented 2 months ago

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 commented 2 months ago

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 commented 2 months ago

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