thunderbird / thunderbird-android

Thunderbird for Android – Open Source Email App for Android (fka K-9 Mail)
https://thunderbird.net/
Apache License 2.0
10.42k stars 2.48k forks source link

DefaultFolderProvider crash #5434

Open cketti opened 3 years ago

cketti commented 3 years ago

From the Google Play developer console App version: 5.800

java.lang.RuntimeException: 
  at android.app.ActivityThread.performLaunchActivity (ActivityThread.java:2927)
  at android.app.ActivityThread.handleLaunchActivity (ActivityThread.java:2988)
  at android.app.ActivityThread.-wrap14 (ActivityThread.java)
  at android.app.ActivityThread$H.handleMessage (ActivityThread.java:1631)
  at android.os.Handler.dispatchMessage (Handler.java:102)
  at android.os.Looper.loop (Looper.java:154)
  at android.app.ActivityThread.main (ActivityThread.java:6682)
  at java.lang.reflect.Method.invoke (Native Method)
  at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run (ZygoteInit.java:1520)
  at com.android.internal.os.ZygoteInit.main (ZygoteInit.java:1410)
Caused by: java.lang.IllegalStateException: 
  at com.fsck.k9.ui.messagelist.DefaultFolderProvider.getDefaultFolder (DefaultFolderProvider.kt:12)
  at com.fsck.k9.activity.MessageList.createDefaultLocalSearch (MessageList.kt:499)
  at com.fsck.k9.activity.MessageList.decodeExtrasToLaunchData (MessageList.kt:489)
  at com.fsck.k9.activity.MessageList.decodeExtras (MessageList.kt:363)
  at com.fsck.k9.activity.MessageList.onCreate (MessageList.kt:180)
  at android.app.Activity.performCreate (Activity.java:6942)
  at android.app.Instrumentation.callActivityOnCreate (Instrumentation.java:1126)
  at android.app.ActivityThread.performLaunchActivity (ActivityThread.java:2880)

It shouldn't be possible to create an account without an Outbox folder, but apparently it is :cry:

rancidfrog commented 3 years ago

Is it possible that k9mail used 1 outbox folder for all accounts? I believe that was the case.

As I have the same issue after updating, but never had an issue with sending mails from default account:

cketti commented 3 years ago

Is it possible that k9mail used 1 outbox folder for all accounts? I believe that was the case.

No. Every account has its own Outbox.

If you're getting this exception it means there's also no Inbox folder. So I'm guessing something went wrong during the upgrade process.

cketti commented 3 years ago

@rancidfrog: Do you run a debug build or have a rooted device? Then you could grab the database files and provide more insights into what has happened.

rancidfrog commented 3 years ago

I am rooted. The databeses have been corrupted. Before from backup, sizes are bigger MBs:

After update, sizes seem to be defaulted nothing in MBs:

dbs have been cleared or something in update process

cketti commented 3 years ago

Thanks. If something goes wrong during the migration we recreate the database. In that case no Outbox folder is created. That explains the crash. I'm not yet sure what's the best way to fix this.

It's great that you have a backup of the old database files. If you have some free time on your hands I could send you a debug version of K-9 Mail that crashes when upgrading the database fails. That way we could find out what caused the migration to fail (although it might be too late for most affected users because their database has already been reset).

rancidfrog commented 3 years ago

@cketti If you send me the debug version, I will see if and when I have time. That way maybe at least we know what the culprit is.

cketti commented 3 years ago

k9mail-debug-5.801.zip

The debug build is using a different application ID. So it can be installed parallel to the release version.

rancidfrog commented 3 years ago

@cketti But, then how does it check migration issues? Since, it will not be updating anything. The whole point is for it to update previous version, no? That way we encounter the migration error and it gets logged. Am I missing anything?

What I thought the process would be,

  1. Restore previous k9mail version
  2. Install debug version, on top of backup
  3. Encounter the issue with migration on update, from old backup to debug, that way log of error is created
cketti commented 3 years ago

Right, sorry. I was thinking:

  1. Install the debug build but don't start the app.
  2. Copy the files from your backup to the data directory of the debug app.
  3. Then start the app.
  4. The app should crash during the migration. Grab logcat output.
rancidfrog commented 3 years ago

@cketti I have to copy all files under data - /data/data/com.fsck.k9 ? And then open. Will see what I can do

cketti commented 3 years ago

The files from the backup that originally existed under /data/data/com.fsck.k9/databases/ should be copied to /data/data/com.fsck.k9.debug/databases/.

k9-issue commented 3 years ago

The migration to the new version also failed for me. I think the old version was v5.705. On first start after the update, k9 crashed and all my folders are not migrated, so I can't access my data (inbox, send, draft). k9 created a new empty inbox, but no outbox and no draft. If I try to send a mail, everything seems to be ok, but if I push the send button, the mail just disappears, the sender does not receive it and it seems to be stored nowhere. I'm using F-Droid, is it possible to get my data back and to help you to fix this issue? The phone is not rooted, if I root it now, all user data will be deleted, so this won't help. I found this in the log:

java.lang.IllegalStateException: Outbox missing
       at com.fsck.k9.ui.messagelist.DefaultFolderProvider.getDefaultFolder(DefaultFolderProvider.kt:12)
       at com.fsck.k9.widget.unread.UnreadWidgetDataProvider.getClickIntentForAccount(UnreadWidgetDataProvider.kt:60)
       at com.fsck.k9.widget.unread.UnreadWidgetDataProvider.loadAccountData(UnreadWidgetDataProvider.kt:54)
       at com.fsck.k9.widget.unread.UnreadWidgetDataProvider.loadUnreadWidgetData(UnreadWidgetDataProvider.kt:32)
       at com.fsck.k9.widget.unread.UnreadWidgetRepository.getWidgetData(UnreadWidgetRepository.kt:33)
       at com.fsck.k9.provider.UnreadWidgetProvider.updateWidgets(UnreadWidgetProvider.kt:44)
       at com.fsck.k9.provider.UnreadWidgetProvider.access$updateWidgets(UnreadWidgetProvider.kt:30)
       at com.fsck.k9.provider.UnreadWidgetProvider$onUpdate$1.invokeSuspend(UnreadWidgetProvider.kt:37)
       at kotlin.coroutines.jvm.internal.BaseContinuationImpl.resumeWith(ContinuationImpl.kt:33)
       at kotlinx.coroutines.DispatchedTask.run(DispatchedTask.kt:106)
       at kotlinx.coroutines.scheduling.CoroutineScheduler.runSafely(CoroutineScheduler.kt:571)
       at kotlinx.coroutines.scheduling.CoroutineScheduler$Worker.executeTask(CoroutineScheduler.kt:750)
       at kotlinx.coroutines.scheduling.CoroutineScheduler$Worker.runWorker(CoroutineScheduler.kt:678)
       at kotlinx.coroutines.scheduling.CoroutineScheduler$Worker.run(CoroutineScheduler.kt:665)
rancidfrog commented 3 years ago

So, This is what I got after copying database folder after installing debug; First, I corrected permissions Then, Opened app after initiating logcat: https://pastebin.pl/view/226e2f0b

Let me know if it logged what you need. I had to change permissions one by one for each file in db, as the file explorer did not do it automatically after setting permission of folder.

cketti commented 3 years ago

@rancidfrog: Did you copy the database files from your 5.600 backup? It doesn't look like the app is running the database migrations.

rancidfrog commented 3 years ago

@cketti No, the update that I have is of 5.300, as I have not been using k9mail for a while now, since it stopped working for gmail.

Do I need to update to a specific version and try again? I have the older version up and running. So, which version would be needed?

cketti commented 3 years ago

That explains it. K-9 Mail now only supports upgrades from 5.301 and newer. When upgrading from earlier versions it will recreate the message database. You could try going to 5.600, then to 5.802.