dbaroncelli / D-KMP-sample

D-KMP Architecture official sample: it uses a shared KMP ViewModel and Navigation for Compose and SwiftUI apps.
Apache License 2.0
818 stars 89 forks source link

App not working for android < 26. #5

Closed raghavpai closed 3 years ago

raghavpai commented 3 years ago

dependencies { coreLibraryDesugaring("com.android.tools:desugar_jdk_libs:1.0.9") }

compileOptions {
    sourceCompatibility = JavaVersion.VERSION_1_8
    targetCompatibility = JavaVersion.VERSION_1_8
    // Flag to enable support for the new language APIs
    isCoreLibraryDesugaringEnabled = true
}

This is necessary as the app crashes in lower API versions due to as per https://developer.android.com/studio/write/java8-support#library-desugaring

java.lang.NoClassDefFoundError: Failed resolution of: Ljava/time/Instant;
at kotlinx.datetime.Instant.<clinit>(Instant.kt:93)
at kotlinx.datetime.Clock$System.now(Clock.kt:17)

Due to GetCountriesList.kt
Line 13 -> val nowUnixtime = Clock.System.now().epochSeconds
dbaroncelli commented 3 years ago

Hi @raghavpai, which of these 3 Android API settings are you referring to?

dbaroncelli commented 3 years ago

minSdk is set to 21, as this is the requirement for JetpackCompose. compileSdk and targetSdk are set to the latest (30). Not sure what's the reason you would like to compile or target a lower API.

raghavpai commented 3 years ago

When you try to use the App in my case I am using Lollipop android version .....I am getting runtime exception....You can try the APP in lower android version (<26 API version)devices.

raghavpai commented 3 years ago

minSdk is set to 21, as this is the requirement for JetpackCompose. compileSdk and targetSdk are set to the latest (30). Not sure what's the reason you would like to compile or target a lower API.

No issues here this is fine.

dbaroncelli commented 3 years ago

Thanks for pointing this out. I wasn't aware of this crashing for devices below API 26. I have now pushed an update.