Android saving service issues
We have two crashes on Android caused by our background service. Here are the two stacktraces as reported by Play Console:
Crash 1
```
Exception java.lang.RuntimeException:
at android.app.ActivityThread.performPauseActivityIfNeeded (ActivityThread.java:5111)
at android.app.ActivityThread.performPauseActivity (ActivityThread.java:5060)
at android.app.ActivityThread.handlePauseActivity (ActivityThread.java:5012)
at android.app.servertransaction.PauseActivityItem.execute (PauseActivityItem.java:47)
at android.app.servertransaction.ActivityTransactionItem.execute (ActivityTransactionItem.java:45)
at android.app.servertransaction.TransactionExecutor.executeLifecycleState (TransactionExecutor.java:177)
at android.app.servertransaction.TransactionExecutor.execute (TransactionExecutor.java:98)
at android.app.ActivityThread$H.handleMessage (ActivityThread.java:2252)
at android.os.Handler.dispatchMessage (Handler.java:106)
at android.os.Looper.loopOnce (Looper.java:201)
at android.os.Looper.loop (Looper.java:288)
at android.app.ActivityThread.main (ActivityThread.java:7941)
at java.lang.reflect.Method.invoke
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run (RuntimeInit.java:553)
at com.android.internal.os.ZygoteInit.main (ZygoteInit.java:1003)
Caused by android.app.BackgroundServiceStartNotAllowedException:
at android.app.ContextImpl.startServiceCommon (ContextImpl.java:1862)
at android.app.ContextImpl.startService (ContextImpl.java:1818)
at android.content.ContextWrapper.startService (ContextWrapper.java:776)
at org.krita.android.MainActivity.startForegroundServiceS (MainActivity.java:128)
at org.krita.android.MainActivity.startServiceGeneric (MainActivity.java:111)
at org.krita.android.MainActivity.onPause (MainActivity.java:102)
at android.app.Activity.performPause (Activity.java:8244)
at android.app.Instrumentation.callActivityOnPause (Instrumentation.java:1530)
at android.app.ActivityThread.performPauseActivityIfNeeded (ActivityThread.java:5099)
```
Crash 2
```
Exception java.lang.UnsatisfiedLinkError: No implementation found for void org.krita.android.JNIWrappers.saveState() (tried Java_org_krita_android_JNIWrappers_saveState and Java_org_krita_android_JNIWrappers_saveState__) - is the library loaded, e.g. System.loadLibrary?
at org.krita.android.JNIWrappers.saveState (JNIWrappers.java)
at org.krita.android.DocumentSaverService$1.run (DocumentSaverService.java:120)
at java.lang.Thread.run (Thread.java:1012)
```
The usual steps to reproduce the crashes:
1) Create some document
2) Minimize the app
3) Close the minimized app by swiping it out of the screen
issue