Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

App crashes on start up, previous fix did not solve. #126

Open
brokenbadger opened this issue Oct 26, 2024 · 25 comments
Open

App crashes on start up, previous fix did not solve. #126

brokenbadger opened this issue Oct 26, 2024 · 25 comments
Labels
bug Something isn't working

Comments

@brokenbadger
Copy link

Since last update, app crashes on boot screen (logo).
Cannot use.

@brokenbadger
Copy link
Author

Installed fix, but same issue persists.
I have not imported or exported data before as was previously asked?

@AdamGuidarini AdamGuidarini added the bug Something isn't working label Oct 26, 2024
@AdamGuidarini
Copy link
Owner

AdamGuidarini commented Oct 26, 2024

I might need you to pull the logcat for this since I'm struggling to reproduce it. It's a bit of an lengthy process unfortunately.

You'll need to use the Android debug bridge (adb) which you can get either as part of Android Studio or in a zip file with only the command line tools (toward the bottom of the page). Although if you're using a Linux distribution you can install them from your package manager:

Android CLI tools and Android Studio: https://developer.android.com/studio

Debian/Ubuntu based distros:
sudo apt-get install android-sdk-platform-tools

For Fedora/SUSE-based distros:
sudo dnf install android-tools

Here's a pretty good guide I came across for how to use just the adb command line tool:

https://www.xda-developers.com/install-adb-windows-macos-linux/

Once installed and with you device connected, you can pull the logs with this command: adb logcat --buffer=crash

Alternatively,
You can also try using an Android app like this: https://f-droid.org/en/packages/com.f0x1d.logfox/ This was the easiest way I found to get logs without using Android Studio or having adb throw all the logs at you for the entire system

You will need to give the app permission to read logs through the adb though with this command
adb shell pm grant com.f0x1d.logfox android.permission.READ_LOGS

This app also has a filter option where you can enter projects.medicationtracker to get only the logs from this app

You can also use Android Studio, but that's a bigger download: https://developer.android.com/studio/debug/logcat

Sorry this is kind of an involved process, but since I'm struggling to get it to crash this data would go a long way helping me find the cause of the crashing.

Resetting or reinstalling the app would probably work as well if you need the app to launch again as soon as possible, but it's not ideal as the app data will be deleted and the this bug will still be out there

@K4LCIFER
Copy link

I just installed 0.13.1 and I'm still experiencing the crash. If I have a moment tomorrow, I'll try to export the logs.

@AdamGuidarini
Copy link
Owner

Thank you! Sorry again for the inconvenience. Let me know if there's anything I can do to help!

@brokenbadger
Copy link
Author

I just installed 0.13.1 and I'm still experiencing the crash. If I have a moment tomorrow, I'll try to export the logs.

If you're unable to do it, I'll give it a go one evening?

@avipars
Copy link
Contributor

avipars commented Oct 28, 2024

Same issue here with app crashing

@abePdIta
Copy link

Hi, I have the same problem.
I was able to get a logcat. Here it is:
logcat.txt
I hope it helps and that you can recover the DB.

@AdamGuidarini
Copy link
Owner

Unfortunately it looks like the database has become corrupted and it doesn't seem like there's much I can to restore it via an update. I can however take a few measures to ensure the app is less likely to corrupt the database and able to handle it becoming corrupted more gracefully.

Here's my current plan:

  • Check when the database is being opened and close to ensure there's only one open instance of it at a time.
  • Periodically create a backup of the database so that in the event it becomes corrupted, it can restore a known good database. This may result in some data lose, but that's better than total data lose.
  • Add an option for database exporting (in the same way as going into settings and exporting by tapping the "Export" button) on a fixed interval or whenever a change is made (this would be up to the user).

To get the app working again, the only solution is likely to clear the app's storage unfortunately. Here's a guide for how to do that https://www.androidcentral.com/how-and-when-clear-app-cache-or-data-android. It's far from ideal, but when searching for it a solution I can add via an update, I couldn't find a way to restore a broken database, other than by creating a copy of it periodically and using that to restore the database if it becomes corrupt.

I'll switch from the feature I've been working on over to this as the top priority for the app and I'll tag my commits and pull requests to this issue to keep progress visible. Sorry about the inconvenience, I'll do my best to get this out soon and I'll post updates here

@K4LCIFER
Copy link

Wait so all existing data in the app is corrupted? That's rather unfortunate. Do you know what caused it? It would likely be something that was changed in the previous update.

@abePdIta
Copy link

I agree with K4lcifer 🔥 : it's a little weird that most of us are experiencing the same issue (database corruption) at the same time. Maybe is there a root cause that can be avoided or fixed without too much of effort.
That been said, I wish to thank the developer and maintainer of this project. I understand that, right now, you are feeling the pressure of your app failing to work properly and loosing data… but, please, don't.
You're doing this for free, in your free time, asking nothing in return. It's okay to be concerned, but don't let concern get the best of you. I know of many FOSS developers who have gone into burn-out because of this.

And, to anyone else, please, be patient. 😉

@AdamGuidarini
Copy link
Owner

I'm sure there's something I could patch to prevent it, but I haven't managed to find it yet sadly. Someone I know personally had a similar crash on launch issue, but cleared the app data before I could get to the device and check out the logs (I didn't think to look into the methods I mentioned earlier). Could have been the same issue, or something unrelated. I'm somewhat suspecting that there could be 2 or processes writing to the database a the same time, corrupting the data. But I haven't been able to verify this yet.

I don't think I'll have a whole lot of time to work on it this weekend because of a family event, but early next week I should have time to investigate further and implement methods to handle corruption and mitigate the damage if the other methods don't resolve the issue.

@brokenbadger
Copy link
Author

Just tried an uninstall, clean with SD Maid and then fresh install of the latest...... Same issue.
There's something in the past couple of APK's that doesn't play nicely with my phone config?

@brokenbadger
Copy link
Author

v0.13.1 is the latest I can clean install and get working.
Previously just updating to the latest via obtainium would just fail.

@abePdIta
Copy link

abePdIta commented Nov 22, 2024 via email

@AdamGuidarini
Copy link
Owner

It could be something phone specific, but I can't say for sure unfortunately. Are you using a standard version of Android (with Google services) or something like GrapheneOS, Lineage OS, Calyx OS, etc...? I believe most of these release an ISO for use in a virtual machine I could try testing with.

I use my own Google Pixel 6 (Android 15) and the Android images Google provides through Android studio for testing so a different Android image could behave differently. But it's hard to say whether or not that's related to the problem.

I checked the comparison between 0.13.1 and 0.13.3, but there don't seem to be any changes that would cause issues like that. At least that I can see. Both use the same minimum (29 - Android 10), compile (34 - Android 14), and target (34 - Android 14) SDK versions for example and have the same permissions.

I did try install 0.13.1, 0.13.2, and 0.13.3 in an emulator, but they didn't display any issues, I'll try testing some more in the coming days, but I'll be traveling to visit family this week so I might not have much time until December 1.

@abePdIta
Copy link

Stock Android with Google services for me. More details in private, if you wish.

@brokenbadger
Copy link
Author

brokenbadger commented Nov 23, 2024

I'll second @abePdIta. Stock Android with Google services.

The plot thickens.......

@AdamGuidarini
Copy link
Owner

Stock Android with Google services for me. More details in private, if you wish.

I'll take any details you can give honestly, [email protected] is the email I set up for stuff like this. Might not lead to the needed answer, but it could rule out some hardware related issues and allow me to configure an emulator my similar to your specific device.

Any logs could also be helpful if anyone has time to get them, since if this is a clean install of the app, I feel like the database is malformed error is less likely to be the cause.

@avipars
Copy link
Contributor

avipars commented Nov 27, 2024

Stock Android with Google services for me. More details in private, if you wish.

I'll take any details you can give honestly, [email protected] is the email I set up for stuff like this. Might not lead to the needed answer, but it could rule out some hardware related issues and allow me to configure an emulator my similar to your specific device.

Any logs could also be helpful if anyone has time to get them, since if this is a clean install of the app, I feel like the database is malformed error is less likely to be the cause.

For me, the issue only occurred after I updated the app to version 0.13.2, I looked briefly at the commit history and there were changes made recently that involved some SQL queries. If I had to guess, it could be a migration issue or something related to the app and not the users.

@AdamGuidarini
Copy link
Owner

It's definitely possible the issue is in there, but I'm confused why clean installs of the app work fine in the emulator when I've tested. Updates have also gone smoothly there as well as on my own device. That's the main reason why I've been wondering if it's an issue with some specific devices.

@brokenbadger
Copy link
Author

Just to add to the mystery, I had downgraded to V.0.13.1 as was latest version that worked for me...... until now.

Took a chance and upgraded from V0.13.1 directly to V.0.13.4 and all went perfectly with database intact!
Good luck working that one out? 😂

@abePdIta would highly recommend giving it a go.

@AdamGuidarini
Copy link
Owner

Well, I'm glad it's working! 0.13.4a bug fix that @avipars found and helped fix. It stopped crashes when you entered a "." before any other number for dosage. Just adding onto the confusion I guess 😆

I'll keep working on finding the cause and building up the data corruption mitigations

@brokenbadger
Copy link
Author

All good, thanks again for creating this little gem. It may be niche, but it's become essential for me.

@abePdIta
Copy link

@brokenbadger Thanks for the hint! It worked!
@AdamGuidarini Ah, that's really interesting! I do have a "." as first character of my dosage unit field.
This is because, at the time, I tried to enter 0.5 in the dosage and it didn't let me.
Now it works as expected and I'm also able to enter 0.5 as value!
Thank you very much for your effort! 😉👍

@avipars
Copy link
Contributor

avipars commented Jan 8, 2025

My pull request doesn't touch the SQL / DataBase at all so I don't think it adds any confusion.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

When branches are created from issues, their pull requests are automatically linked.

5 participants