Skip to content

Enable java 8 features on android < 26#1035

Merged
MGaetan89 merged 6 commits intomainfrom
fix-crash-android-above-26
May 26, 2025
Merged

Enable java 8 features on android < 26#1035
MGaetan89 merged 6 commits intomainfrom
fix-crash-android-above-26

Conversation

@StaehliJ
Copy link
Contributor

@StaehliJ StaehliJ commented May 19, 2025

Pull request

Description

This PR fixes issues with android device running with Android < 26 using java8 features. For example when using feature from kotlinx-datetime.

It will throw a following error related to exception Didn't find class "java.time.Instant". 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:95)
             	at kotlinx.datetime.Clock$System.now(Clock.kt:54)
             	at ch.srg.sandbox.pillarbox.sandbox.MyApplication.onCreate(MyApplication.kt:24)
             	at android.app.Instrumentation.callApplicationOnCreate(Instrumentation.java:1024)
             	at android.app.ActivityThread.handleBindApplication(ActivityThread.java:5361)
             	at android.app.ActivityThread.-wrap2(ActivityThread.java)
             	at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1528)
             	at android.os.Handler.dispatchMessage(Handler.java:102)
             	at android.os.Looper.loop(Looper.java:154)
             	at android.app.ActivityThread.main(ActivityThread.java:6077)
             	at java.lang.reflect.Method.invoke(Native Method)
             	at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:866)
             	at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:756)
             Caused by: java.lang.ClassNotFoundException: Didn't find class "java.time.Instant" on path:

Changes made

  • Add jdk desugar library and corresponding configuration
  • Update README

Checklist

  • APIs have been properly documented (if relevant).
  • The documentation has been updated (if relevant).
  • New unit tests have been written (if relevant).
  • The demo has been updated (if relevant).

@StaehliJ StaehliJ force-pushed the fix-crash-android-above-26 branch from 17f5b56 to fd15a2d Compare May 19, 2025 07:41
@github-actions
Copy link

github-actions bot commented May 19, 2025

Code Coverage

Overall Project 50.81% -0.14% 🟢
Files changed 0% 🟢

Module Coverage
Kover Gradle Plugin XML report for :plugins 6.79% -2.76% 🟢
Files
Module File Coverage
Kover Gradle Plugin XML report for :plugins PillarboxAndroidApplicationPlugin.kt 0% -8.4% 🟢
PillarboxAndroidLibraryPlugin.kt 0% -17.54% 🟢
ProjectExtensions.kt 0% -2.14% 🟢

@StaehliJ StaehliJ marked this pull request as ready for review May 19, 2025 08:11
@StaehliJ StaehliJ requested a review from MGaetan89 May 19, 2025 08:11
@MGaetan89 MGaetan89 moved this from 📋 Backlog to 🍿 Code Review in Pillarbox May 19, 2025
@MGaetan89 MGaetan89 added this pull request to the merge queue May 26, 2025
Merged via the queue into main with commit 0e4b4bf May 26, 2025
10 checks passed
@MGaetan89 MGaetan89 deleted the fix-crash-android-above-26 branch May 26, 2025 08:40
@github-project-automation github-project-automation bot moved this from 🍿 Code Review to ✅ Done in Pillarbox May 26, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: ✅ Done

Development

Successfully merging this pull request may close these issues.

2 participants