Sav22999 / common-voice-android

Repository of "CV Project" app. It's an unofficial app for Mozilla Common Voice, which permits you to contribute to this project via your device.
https://www.saveriomorelli.com/commonvoice/
GNU General Public License v3.0
108 stars 18 forks source link

[BUG] Crash on android S+ (API >= 31) #194

Open Damjan94 opened 2 years ago

Damjan94 commented 2 years ago

General information

About OS*

OS version: Android 12 LineageOS 19

About the app (CV Project)*

App release: built from master branch

App language (in English): English

About you device

Device RAM: ?

Device display size (in Inches): ?

(Optional, but recommended) Device model (and brand): dream2lte

From what store have you installed the app?: built from source

Are there installed Google Services on your device? No

Description bug *

The app crashes on startup

How to reproduce the bug *

  1. Start the app

Log file

No log file as the app doesn't start. Here's a stack trace instead

E/AndroidRuntime: FATAL EXCEPTION: pool-3-thread-1
    Process: org.commonvoice.saverio, PID: 10436
    java.lang.IllegalArgumentException: org.commonvoice.saverio: Targeting S+ (version 31 and above) requires that one of FLAG_IMMUTABLE or FLAG_MUTABLE be specified when creating a PendingIntent.
    Strongly consider using FLAG_IMMUTABLE, only use FLAG_MUTABLE if some functionality depends on the PendingIntent being mutable, e.g. if it needs to be used with inline replies or bubbles.
        at android.app.PendingIntent.checkFlags(PendingIntent.java:375)
        at android.app.PendingIntent.getBroadcastAsUser(PendingIntent.java:645)
        at android.app.PendingIntent.getBroadcast(PendingIntent.java:632)
        at androidx.work.impl.utils.ForceStopRunnable.getPendingIntent(ForceStopRunnable.java:273)
        at androidx.work.impl.utils.ForceStopRunnable.isForceStopped(ForceStopRunnable.java:151)
        at androidx.work.impl.utils.ForceStopRunnable.forceStopRunnable(ForceStopRunnable.java:171)
        at androidx.work.impl.utils.ForceStopRunnable.run(ForceStopRunnable.java:102)
        at androidx.work.impl.utils.SerialExecutor$Task.run(SerialExecutor.java:91)
        at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1167)
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:641)
        at java.lang.Thread.run(Thread.java:920)
Sav22999 commented 2 years ago

@Damjan94 Hi, sorry for this bug.

Have you tried the last version released in "Release"? (2.4.0.4)... it should work.

Update me 😄

Damjan94 commented 2 years ago

It does not work, sorry... Does it work on your emulator(running api >= 31 ?) maybe the problem is not there(even though the stack trace strongly suggests that it is). I have had a few apps crash on me before, because of no google play services(something as simple as using google's font could cause a crash if services aren't installed.)

Damjan94 commented 2 years ago

So, according to this https://github.com/firebase/flutterfire/issues/7237#issuecomment-951616172 and this https://github.com/firebase/flutterfire/issues/8018 if you use an old library, it could also cause the crash

Sav22999 commented 2 years ago

@Damjan94 I don't really know actually

Damjan94 commented 2 years ago

ok I fixed it. It was indeed an outdated library. Changing the workVersion to 2.8.0-alpha02

diff --git a/buildSrc/src/main/java/Versions.kt b/buildSrc/src/main/java/Versions.kt
-    const val workVersion = "2.5.0"
+    const val workVersion = "2.8.0-alpha02"

I hope there's nothing preventing you from updating that dependency. Good luck.

Sav22999 commented 2 years ago

@Damjan94 I cannot merge with an alpha version, the app could be unstable (alpha version for definition is not stable).

Could you try with 2.8.0 instead?

Thank you very much

Damjan94 commented 2 years ago

The latest stable version is 2.7.1 and it works there too.

Sav22999 commented 2 years ago

@Damjan94 Thanks! I'll update asap 😄

Roy-Orbison commented 1 year ago

@Sav22999 Has there been a regression on this one? The app crashes so frequently it's barely usable, but I'm pretty sure it only started crashing after I logged into it. I get this log with v2.5.1:

java.lang.IllegalArgumentException: org.commonvoice.saverio: Targeting S+ (version 31 and above) requires that one of FLAG_IMMUTABLE or FLAG_MUTABLE be specified when creating a PendingIntent.
Strongly consider using FLAG_IMMUTABLE, only use FLAG_MUTABLE if some functionality depends on the PendingIntent being mutable, e.g. if it needs to be used with inline replies or bubbles.
    at android.app.PendingIntent.checkFlags(PendingIntent.java:377)
    at android.app.PendingIntent.getActivityAsUser(PendingIntent.java:460)
    at android.app.PendingIntent.getActivity(PendingIntent.java:446)
    at android.app.PendingIntent.getActivity(PendingIntent.java:410)
    at org.commonvoice.saverio.ListenActivity.sendNotification(ListenActivity.kt:1533)
    at org.commonvoice.saverio.ListenActivity.showPopupAndSendNotification(ListenActivity.kt:1498)
    at org.commonvoice.saverio.ListenActivity.access$showPopupAndSendNotification(ListenActivity.kt:66)
    at org.commonvoice.saverio.ListenActivity$setupBadgeDialog$1$invokeSuspend$$inlined$collect$1.emit(Collect.kt:146)
    at kotlinx.coroutines.flow.SharedFlowImpl.collect(SharedFlow.kt:351)
    at kotlinx.coroutines.flow.SharedFlowImpl$collect$1.invokeSuspend(Unknown Source:15)
    at kotlin.coroutines.jvm.internal.BaseContinuationImpl.resumeWith(ContinuationImpl.kt:33)
    at kotlinx.coroutines.DispatchedTaskKt.resume(DispatchedTask.kt:234)
    at kotlinx.coroutines.DispatchedTaskKt.resumeUnconfined(DispatchedTask.kt:190)
    at kotlinx.coroutines.DispatchedTaskKt.dispatch(DispatchedTask.kt:161)
    at kotlinx.coroutines.CancellableContinuationImpl.dispatchResume(CancellableContinuationImpl.kt:397)
    at kotlinx.coroutines.CancellableContinuationImpl.resumeImpl(CancellableContinuationImpl.kt:431)
    at kotlinx.coroutines.CancellableContinuationImpl.resumeImpl$default(CancellableContinuationImpl.kt:420)
    at kotlinx.coroutines.CancellableContinuationImpl.resumeWith(CancellableContinuationImpl.kt:328)
    at kotlinx.coroutines.flow.SharedFlowImpl.emitSuspend(SharedFlow.kt:472)
    at kotlinx.coroutines.flow.SharedFlowImpl.emit(SharedFlow.kt:374)
    at org.commonvoice.saverio_lib.preferences.StatsPrefManager$localValidated$1.invokeSuspend(StatsPrefManager.kt:125)
    at kotlin.coroutines.jvm.internal.BaseContinuationImpl.resumeWith(ContinuationImpl.kt:33)
    at kotlinx.coroutines.DispatchedTask.run(DispatchedTask.kt:106)
    at android.os.Handler.handleCallback(Handler.java:938)
    at android.os.Handler.dispatchMessage(Handler.java:99)
    at android.os.Looper.loopOnce(Looper.java:226)
    at android.os.Looper.loop(Looper.java:329)
    at android.app.ActivityThread.main(ActivityThread.java:8063)
    at java.lang.reflect.Method.invoke(Native Method)
    at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:548)
    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1026)
Sav22999 commented 1 year ago

@Roy-Orbison sorry for the inconvenience. Thank you for reporting this. I'll check asap and in case release an update. Please, let me know if the problem still remain after that.

😓

Roy-Orbison commented 1 year ago

No worries, thanks for your good work. I did find this bug report earlier but assumed a fix was on the way. The date looked recent, but I'd misread the year as 2023.