Exodus-Privacy / exodus-android-app

εxodus Android application
GNU General Public License v3.0
649 stars 56 forks source link

Crash - android.app.BackgroundServiceStartNotAllowedException #336

Open Jean-BaptisteC opened 1 year ago

Jean-BaptisteC commented 1 year ago
Exception android.app.BackgroundServiceStartNotAllowedException:
  at android.app.ContextImpl.startServiceCommon (ContextImpl.java:1918)
  at android.app.ContextImpl.startService (ContextImpl.java:1874)
  at android.content.ContextWrapper.startService (ContextWrapper.java:827)
  at android.content.ContextWrapper.startService (ContextWrapper.java:827)
  at org.eu.exodus_privacy.exodusprivacy.MainActivity$startInitial$1.invoke (SourceFile:10)
  at org.eu.exodus_privacy.exodusprivacy.MainActivity$startInitial$1.invoke (SourceFile:1)
  at org.eu.exodus_privacy.exodusprivacy.MainActivity$sam$androidx_lifecycle_Observer$0.onChanged
  at androidx.lifecycle.LiveData.c (SourceFile:30)
  at androidx.lifecycle.LiveData.d (SourceFile:16)
  at androidx.lifecycle.LiveData$c.h (SourceFile:24)
  at androidx.lifecycle.LiveData$LifecycleBoundObserver.d (SourceFile:30)
  at androidx.lifecycle.x$b.a (SourceFile:25)
  at androidx.lifecycle.x.h (SourceFile:83)
  at androidx.lifecycle.x.p (SourceFile:80)
  at androidx.lifecycle.x.l (SourceFile:35)
  at androidx.lifecycle.x.i (SourceFile:15)
  at androidx.lifecycle.l0$b.a (SourceFile:41)
  at androidx.lifecycle.l0$c.onActivityPostStarted (SourceFile:10)
  at android.app.Activity.dispatchActivityPostStarted (Activity.java:1496)
  at android.app.Activity.performStart (Activity.java:8611)
  at android.app.ActivityThread.handleStartActivity (ActivityThread.java:3922)
  at android.app.servertransaction.TransactionExecutor.performLifecycleSequence (TransactionExecutor.java:221)
  at android.app.servertransaction.TransactionExecutor.cycleToPath (TransactionExecutor.java:201)
  at android.app.servertransaction.TransactionExecutor.executeLifecycleState (TransactionExecutor.java:173)
  at android.app.servertransaction.TransactionExecutor.execute (TransactionExecutor.java:97)
  at android.app.ActivityThread$H.handleMessage (ActivityThread.java:2437)
  at android.os.Handler.dispatchMessage (Handler.java:106)
  at android.os.Looper.loopOnce (Looper.java:211)
  at android.os.Looper.loop (Looper.java:300)
  at android.app.ActivityThread.main (ActivityThread.java:8294)
  at java.lang.reflect.Method.invoke
  at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run (RuntimeInit.java:580)
  at com.android.internal.os.ZygoteInit.main (ZygoteInit.java:1028)

https://github.com/Exodus-Privacy/exodus-android-app/blob/78f5d380d42a63ff60b1638e8ea74c84b97af1a7/app/src/main/java/org/eu/exodus_privacy/exodusprivacy/MainActivity.kt#L97

Jean-BaptisteC commented 8 months ago

Some links to help to fix:

theimpulson commented 5 months ago

Migration to WorkManager should be considered that will also allow to automatically update the database in background.

Jean-BaptisteC commented 5 months ago

I didn't like WorkManager:

And with most version of Android, background service is too restrictive and need regularly to update code to respect rules of Google.