sal0max / muzei-nationalgeographic

The National Geographic photo of the day for Muzei.
GNU General Public License v3.0
39 stars 7 forks source link

Android 5+ support #15

Closed kakonema closed 2 years ago

kakonema commented 2 years ago

FDroid build says that app support Android 5+, but the app uses java.time class which is API 26+ (Android 8+). I always though that plugin is dead since it didn't work on my Android 7 system, but after seeing latest activity i checked logcat and found that it throws exception because it cannot find mentioned class. Is there any workaround for this? Thanks

kakonema commented 2 years ago

java.lang.ClassNotFoundException: Didn't find class "java.time.ZoneId" on path: DexPathList[[zip file "/data/app/de.msal.muzei.nationalgeographic-1/base.apk"],nativeLibraryDirectories=[/data/app/de.msal.muzei.nationalgeographic-1/lib/arm, /system/lib, /vendor/lib]]

sal0max commented 2 years ago

This plugin isn't dead. So thanks for the issue. That was a tough one.

  1. There is no usage of classes in the java.time package: https://github.com/sal0max/muzei-nationalgeographic/search?q=java.time

  2. If there was, you'd expect there would be a lint error at compile time, not runtime errors, like in this test I just made:

    
    Lint found 1 error. First failure:
    .../src/main/kotlin/de/msal/muzei/nationalgeographic/ImageDeserializer.kt:17: Error: Call requires API level 26 (current min is 21): java.time.Duration#ofMillis [NewApi]
      val testVariableForDemonstration = java.time.Duration.ofMillis(1000)
                                                            ~~~~~~~~

Lint found errors in the project; aborting build.



However, once I tried it on an Android 5 Emulator I got the same runtime error.

The [dateparser library](https://github.com/sisyphsu/dateparser) is at fault here.
I'll think about a fix for this.
kakonema commented 2 years ago

That makes sense, i also made a search and couldn't find that class in the code , thanks for looking it up. I found something called "coreLibraryDesugaring" which, if i understand correctly, adds android 8 api support for older android versions, hope that this helps

sal0max commented 2 years ago

Desugaring seems to be the solution, correct: https://github.com/sisyphsu/dateparser/issues/6

sal0max commented 2 years ago

Fixed in version https://github.com/sal0max/muzei-nationalgeographic/releases/tag/2.4.3 Should arrive in the App Stores, soon.

Thanks again, for your message. 👍

kakonema commented 2 years ago

Great, works now. Thank you.