code-with-the-italians / bundel

A digital wellbeing Android app that helps minimise distractions when you don't want them. Watch us live code it at https://cwti.link/twitch or catch up on YouTube at https://cwti.link/yt. Merch available at https://cwti.link/spaccio.
https://codewiththeitalians.it
Apache License 2.0
288 stars 26 forks source link

Something is off with WEBP_LOSSLESS support #8

Closed hamen closed 2 years ago

hamen commented 3 years ago

Describe the bug App crashing after giving access to notifications

To Reproduce Steps to reproduce the behavior:

  1. Give permissions
  2. Go back to the app

Expected behavior I would expect to reach the main screen.

Screenshots N.A.

Smartphone (please complete the following information):

Additional context

java.lang.NoSuchFieldError: No static field WEBP_LOSSLESS of type Landroid/graphics/Bitmap$CompressFormat; in class Landroid/graphics/Bitmap$CompressFormat; or its superclasses (declaration of 'android.graphics.Bitmap$CompressFormat' appears in /system/framework/framework.jar)
        at dev.sebastiano.bundel.storage.DiskImagesStorage$ImageFormat.<clinit>(DiskImagesStorage.kt:109)
        at dev.sebastiano.bundel.storage.DiskImagesStorage.getCachedImageFormat(DiskImagesStorage.kt:99)
        at dev.sebastiano.bundel.storage.DiskImagesStorage.getIconFile(DiskImagesStorage.kt:59)
        at dev.sebastiano.bundel.storage.DiskImagesStorage.saveIcon(DiskImagesStorage.kt:37)
        at dev.sebastiano.bundel.storage.DiskImagesStorage.saveIconsFrom(DiskImagesStorage.kt:24)
        at dev.sebastiano.bundel.storage.RobertoRepository.saveNotification(RobertoRepository.kt:15)
        at dev.sebastiano.bundel.storage.RobertoRepository$saveNotification$1.invokeSuspend(Unknown Source:15)
        at kotlin.coroutines.jvm.internal.BaseContinuationImpl.resumeWith(ContinuationImpl.kt:33)
        at kotlinx.coroutines.DispatchedTask.run(DispatchedTask.kt:106)
        at kotlinx.coroutines.EventLoopImplBase.processNextEvent(EventLoop.common.kt:274)
        at kotlinx.coroutines.BlockingCoroutine.joinBlocking(Builders.kt:84)
        at kotlinx.coroutines.BuildersKt__BuildersKt.runBlocking(Builders.kt:59)
        at kotlinx.coroutines.BuildersKt.runBlocking(Unknown Source:1)
        at kotlinx.coroutines.BuildersKt__BuildersKt.runBlocking$default(Builders.kt:38)
        at kotlinx.coroutines.BuildersKt.runBlocking$default(Unknown Source:1)
        at dev.sebastiano.bundel.notifications.BundelNotificationListenerService.onListenerConnected(BundelNotificationListenerService.kt:30)
        at android.service.notification.NotificationListenerService$MyHandler.handleMessage(NotificationListenerService.java:2076)
        at android.os.Handler.dispatchMessage(Handler.java:107)
        at android.os.Looper.loop(Looper.java:237)
        at android.app.ActivityThread.main(ActivityThread.java:8167)
        at java.lang.reflect.Method.invoke(Native Method)
        at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:496)
        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1100)
rock3r commented 3 years ago

The issue is likely that the classloader loads the field because it's defined eagerly as part of the enum declaration. We should either use reflection (it's a small, one-off cost) or move the value into a function that loads it lazily as needed.

rock3r commented 2 years ago

Fixed on 24/12