I use automate to disable android sync in the evening and enable it again in the morning. K9 doesn't always pick this up correctly. I thought to solve this issue by enabling "always sync" in the network settings but even then the sync stays disabled in the morning.
Switch correctly between enabling and disabling sync when the option is changed in Android and respect the "sync always on" option in K9.
Disabling of the sync seems to work correctly but enabling doesn't always work correctly. Sync stays disabled for several, or all, mail accounts in K9.
K-9 Mail version:
5.600 (2 September update)
Android version:
8.0.0 (1 September update)
Account type (IMAP, POP3, WebDAV/Exchange):
IMAP accounts
Can confirm it with LineageOS 15.1 (Android 8.1) and IMAP accounts
Same here. Syncing is disabled message is shown all the time. Battery optimization is disabled and background sync is set to Always.
I had this issue a long time ago.
I got a one plus5t and trying various roms (had other issues) it worked on stock but after rooting by flashing magisk k9 did the stopping sync thing.
I flashed an older version of magisk and it seems to be working okay now.
Now im no expert but it seems it could be kernel or magisk related.
Does that make any sense to you?
I need k9 for work so if i find a phone it works on I usually buy a few because it has neen ultra fussy what it works on or not.
@Newbie1980 What version of Magisk do you have installed? I have the v17.3 and am willing to use an older version.
I am testing 16 I think. Dont have phone to hand. I am going to checck said phone later.
Also I noticed adaway totally messed up notifications on all apps.
I don't have a rooted phone nor a custom ROM installed. So that can't be the problem on my phone.
Yes but if K9 doesnt like your kernel, flashing another one could make it work.
Not saying it will but it is the only thing I can come up with why it works on some and not others,?
I use stock LineageOS kernel. No root or magisk
Well 9 hours in I can confirm that phone in question is working with the older magisk. It did not work with the most recent.
I thought lineage was rooted as standard?
Are there any kernels you can flash to see if it makes a difference.
Adaway messed up all my notifications too.
But the "always sync" option should at least work, regardless of the kernel you're using. That should just ignore any Android function that might, or might not, be selected.
It should I agree but I don't know if your problem is with automation or k9 itself.
Have u left k9 alone to see if it goes off sync itself.
Automate only switches the android auto sync feature. But regardless what the automate app does I set the K9 sync to "always on" and it isn't always on. It randomly disables and switching android auto sync option fixes it.
Did u read that #857 post?
Ur only option is a different phone or to make k9 think u have a different phone.
Did u read that #857 post?
Ur only option is a different phone or to make k9 think u have a different phone.
I've read the post but I don't think that is related to the problem I am trying to describe here. There is enough moments when my phone is unused for quite a bit of time and I notifications for new emails.
If the sync stays enabled in other apps on my phone (I've tried other mail apps but came back to K9 because I prefer its customizability compared to other highly rated mail apps.)
Later today I will disable the "auto sync" toggle in my automate app and exclude K9 from battery saving settings and see if that solves my problem.
I was also hoping that any of that K9 developers would respond to this issue, or is any of the responders a K9 dev and didn't I notice?
@jerheij for me exclude k9 from battery optimization doesn't make any difference
@jerheij for me exclude k9 from battery optimization doesn't make any difference
Do you also have the sync setting within K9 on "always on"??
@jerheij yes, always
Yesterday evening I've attempted something to see if that helps the issue in any way:
I am still using the Automate app to switch the android auto-sync state and so far it's working okay.
Same problem here. Moto X4, stock ROM, Android 8.0, sync always on, no battery saving. K9 often sets itself to sync disabled. I have to FC and restart it then.
I also have this problem.
Sony Xperia XZ1 G8341,
Android 8.0.0.0
I believe I have disabled all power and data savings modes for this app
Believe it is Android-O restriction on background service. K9 needs to update the source to support android-O new requirements.
Background Execution Limits
Android 8.0: java.lang.IllegalStateException: Not allowed to start service Intent
2019-02-01 07:42:18.372 16792-16792/com.fsck.k9 E/AndroidRuntime: FATAL EXCEPTION: main
Process: com.fsck.k9, PID: 16792
java.lang.RuntimeException: Unable to create application com.fsck.k9.K9: java.lang.IllegalStateException: Not allowed to start service Intent { act=com.fsck.k9.intent.action.MAIL_SERVICE_RESET cmp=com.fsck.k9/.service.MailService (has extras) }: app is in background uid UidRecord{a1bf927 u0a241 RCVR idle procs:1 seq(0,0,0)}
at android.app.ActivityThread.handleBindApplication(ActivityThread.java:6061)
at android.app.ActivityThread.-wrap1(Unknown Source:0)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1764)
at android.os.Handler.dispatchMessage(Handler.java:105)
at android.os.Looper.loop(Looper.java:164)
at android.app.ActivityThread.main(ActivityThread.java:6940)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.Zygote$MethodAndArgsCaller.run(Zygote.java:327)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1374)
Caused by: java.lang.IllegalStateException: Not allowed to start service Intent { act=com.fsck.k9.intent.action.MAIL_SERVICE_RESET cmp=com.fsck.k9/.service.MailService (has extras) }: app is in background uid UidRecord{a1bf927 u0a241 RCVR idle procs:1 seq(0,0,0)}
at android.app.ContextImpl.startServiceCommon(ContextImpl.java:1538)
at android.app.ContextImpl.startService(ContextImpl.java:1484)
at android.content.ContextWrapper.startService(ContextWrapper.java:663)
at com.fsck.k9.service.MailService.actionReset(MailService.java:47)
at com.fsck.k9.K9.setServicesEnabled(K9.java:401)
Thanks for the update! FYI, my Moto X4 now runs Android 9.0, that did not change anything.
If you review the K9 source, all the background services extend CoreServie, in turn extend android services. For apk running on android-O (android-8) or higher, the Background Execution Limits will be enforced. If any of the K9 methods attempts to start a background service, the OS immediately throws
IllegalStateException i.e.
2019-02-04 09:44:12.103 1774-1774/? E/AndroidRuntime: FATAL EXCEPTION: main
Process: com.fsck.K9, PID: 1774
java.lang.RuntimeException: Unable to start receiver com.fsck.k9.service.BootReceiver: java.lang.IllegalStateException: Not allowed to start service Intent { act=com.fsck.k9.intent.action.MAIL_SERVICE_WAKEUP cmp=com.fsck.k9/.service.MailService (has extras) }: app is in background uid UidRecord{36cff0 u0a241 RCVR bg:+4m48s31ms idle procs:1 seq(0,0,0)}
and K9 crashes immediately.
This is the observation on my Note-8 (android-8) and all the PushService, PollService and MailService are not working and K9 mail crashes whenever K9 attempts to start any background services with context.startService(intent) and an error message "K9 has stopped X Close app' appears on the screen.
Hi @cmeng-git, yes, this is a known problem (see #3375) when running target sdk 26 (a requirement from Play Store since November).
Thanks for the clarification
Duplicate of #3950
Workaround for rooted phones: install Magisk and Magisk module 'swap torpedo'. Since then, K9 works as expected on Android 9.0