-
-
Notifications
You must be signed in to change notification settings - Fork 285
Fix Android FileNotFoundException crash in AkavacheBuilder constructor #1110
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
Conversation
Co-authored-by: glennawatson <[email protected]>
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #1110 +/- ##
============================
============================
☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
|
Dont *** send these emails *** girhub i have unsubscribed but still
Getting *** bastard tirn this shit off
Sent from my iPhone
On 6 Sep 2025, at 14:43, Copilot ***@***.***> wrote:
Thanks for assigning this issue to me. I'm starting to work on it and will keep this PR's description up to date as I form a plan and make progress.
Original issue description:
Akavache MAUI Android Crash – PR Summary & Verification
Bug Summary
When initializing Akavache in a .NET MAUI Android project, the app crashes due to invalid cache directory handling.
Initial Crash
android.runtime.JavaProxyThrowable: [System.IO.FileNotFoundException]: /Akavache
at System.Diagnostics.FileVersionInfo.GetVersionInfo
at Akavache.Core.AkavacheBuilder..ctor
at Akavache.CacheDatabase.Initialize
at Akavache.AkavacheBuilderExtensions.WithAkavacheCacheDatabase
Occurs only in Release builds, primarily on Android, with the following setup:
AppBuilder.CreateSplatBuilder()
.WithAkavacheCacheDatabase(builder =>
builder.WithApplicationName(appName)
.WithSqliteDefaults());
Steps to Reproduce
1. Create a new .NET MAUI project.
2. Add Akavache dependency.
3. Initialize Akavache using .WithAkavacheCacheDatabase() as above.
4. Deploy to Android device/emulator, Release build.
5. Observe crash during startup.
Expected Behavior
Akavache should initialize the cache database successfully, using a valid folder path.
Timeline of Issues
Date Stage / Release Status
v11.0 Initial release caused FileNotFoundException due to invalid cache path. ❌
v11.1.1 Added .WithSqliteProvider() and .WithEncryptedSqliteProvider() to simplify initialization. ✅ Fixed original issue, introduced new crash.
Post v11.1.1 Crash moved to /usr read-only directory issue (IOException). ❌
v11.3.3 Fixed by switching from GetMachineStoreForAssembly() → GetMachineStoreForApplication() for mobile platforms. ✅ Needs testing on iOS & upgrade cases.
Root Causes
1. Initial crash
* Akavache attempted to initialize cache using invalid or missing folder paths.
2. Second crash (/usr issue)
* IsolatedStorageFile.GetMachineStoreForAssembly() was being used on Android/iOS,
defaulting to /usr, a read-only location.
* Mobile apps must use:
Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData)
or GetMachineStoreForApplication().
Resolution Implemented
* Akavache now detects mobile platforms and uses platform-appropriate cache locations.
* Added platform constants for Android, iOS, Windows, etc.
* Released as Akavache v11.3.3.
Verification Checklist
Each scenario should be tested and marked as Pass ✅ or Fail ❌.
Platform / Scenario Expected Result Status
Android Emulator (Release) App starts without crash, cache initializes. ⬜
Android Real Device (Pixel 6) Same as above. ⬜
iOS Device App starts without crash, cache initializes. ⬜
WPF Desktop No FileNotFoundException during initialization. ⬜
Upgrade from v10 → v11 Old database reads correctly, migration stable. ⬜
Debug vs Release build Cache location stable across build types. ⬜
If any test fails, please report:
* Device / Platform
* Logs or stack trace
* Steps to reproduce
Related Issues & PRs
* #1058<#1058> – Resolve legacy read with a shim
* #1060<#1060> – Refactor cache directory handling
* #1068<#1068> – Add mobile target frameworks & platform constants
Summary
* Initial crash caused by invalid cache path → fixed in v11.1.1.
* New crash introduced (IOException: /usr) because GetMachineStoreForAssembly was incorrectly
used on mobile platforms → fixed in v11.3.3.
* Fix now uses mobile-safe directories (GetMachineStoreForApplication or
Environment.SpecialFolder.LocalApplicationData).
* Verification is still needed, especially for:
* iOS devices
* Upgrade paths from v10 → v11
* could be legitimately fixed, so verification might be just to say 'its done'
Stack Traces
Application: acars.exe
CoreCLR Version: 9.0.24.52809
.NET Version: 9.0.0
Description: The process was terminated due to an unhandled exception.
Exception Info: System.IO.FileNotFoundException: C:\Users<USERNAME>\AppData\Local\vmsacars\current
at System.Diagnostics.FileVersionInfo.GetVersionInfo(String fileName)
at Akavache.Core.AkavacheBuilder..ctor() in c:\temp\releaser\Akavache\src\Akavache.Core\Core\AkavacheBuilder.cs:line 42
at Akavache.CacheDatabase.Initialize[T](Action1 configure, String applicationName) in c:\temp\releaser\Akavache\src\Akavache.Core\CacheDatabase.cs:line 201 at Akavache.AkavacheBuilderExtensions.WithAkavacheCacheDatabase[T](AppBuilder builder, Action1 configure, String applicationName) in c:\temp\releaser\Akavache\src\Akavache.Core\AkavacheBuilderExtensions.cs:line 43
at Acars.Client.Windows.Program.<CreateHost>g__ConfigureServices|2_7(IServiceCollection s)
at Acars.Client.Windows.Program.<>c.<CreateHost>b__2_2(HostBuilderContext ctx, IServiceCollection svc)
at Microsoft.Extensions.Hosting.HostBuilder.InitializeServiceProvider()
at Microsoft.Extensions.Hosting.HostBuilder.Build()
at Acars.Client.Windows.Program.Main()
android.runtime.JavaProxyThrowable: [System.IO.IOException]: Read-only file system : '/usr'
at System.IO.FileSystem.CreateParentsAndDirectory + 0x9d(Unknown Source)
at System.IO.FileSystem.CreateDirectory + 0x4e(Unknown Source)
at System.IO.FileSystem.CreateDirectory + 0x0(Unknown Source)
at System.IO.Directory.CreateDirectory + 0x12(Unknown Source)
at System.IO.IsolatedStorage.Helper.CreateDirectory + 0x0(Unknown Source)
at System.IO.IsolatedStorage.IsolatedStorageFile..ctor + 0x10d(Unknown Source)
at System.IO.IsolatedStorage.IsolatedStorageFile.GetStore + 0x0(Unknown Source)
at System.IO.IsolatedStorage.IsolatedStorageFile.GetMachineStoreForAssembly + 0x0(Unknown Source)
at Akavache.AkavacheBuilderExtensions.GetIsolatedCacheDirectory + 0x7b(Unknown Source)
at Akavache.Sqlite3.AkavacheBuilderExtensions.CreateSqliteCache + 0x48(Unknown Source)
at Akavache.Sqlite3.AkavacheBuilderExtensions.WithSqliteDefaults + 0x4b(Unknown Source)
android.runtime.JavaProxyThrowable: [System.IO.FileNotFoundException]: /Akavache
at System.Diagnostics.FileVersionInfo.GetVersionInfo + 0x18(Unknown Source)
at Akavache.Core.AkavacheBuilder..ctor + 0x88(Unknown Source)
at Akavache.CacheDatabase.CreateBuilder + 0x0(Unknown Source)
at Akavache.CacheDatabase.Initialize + 0xe(Unknown Source)
at Akavache.AkavacheBuilderExtensions.WithAkavacheCacheDatabase + 0xe(Unknown Source)
Attempted Fix
* Use IsolatedStorage with platform specific TFMs included in the project, rather than relying on .net standard 2.0. So now the mobile specific logic kicks in.
Fixes #1055<#1055>.
…________________________________
✨ Let Copilot coding agent set things up for you<https://github.com/reactiveui/Akavache/issues/new?title=%E2%9C%A8+Set+up+Copilot+instructions&body=Configure%20instructions%20for%20this%20repository%20as%20documented%20in%20%5BBest%20practices%20for%20Copilot%20coding%20agent%20in%20your%20repository%5D%28https://gh.io/copilot-coding-agent-tips%29%2E%0A%0A%3COnboard%20this%20repo%3E&assignees=copilot> — coding agent works faster and does higher quality work when set up for your repo.
________________________________
You can view, comment on, or merge this pull request online at:
#1110
Commit Summary
* c216e57<c216e57> Initial plan
File Changes
(0 files<https://github.com/reactiveui/Akavache/pull/1110/files>)
Patch Links:
* https://github.com/reactiveui/Akavache/pull/1110.patch
* https://github.com/reactiveui/Akavache/pull/1110.diff
—
Reply to this email directly, view it on GitHub<#1110>, or unsubscribe<https://github.com/notifications/unsubscribe-auth/ACCMOBULVJPRUVDQS3DBX233RLQGDAVCNFSM6AAAAACFZOMHW6VHI2DSMVQWIX3LMV43ASLTON2WKOZTGM4TAMRQGI2TGNA>.
You are receiving this because you are subscribed to this thread.Message ID: ***@***.***>
|
|
@mztariq please don't swear, its not appropriate and any further actions like this will result in a ban. You'll need to go to the repo and unsubscribe to the Akavache repo if you don't want the notificaitons. |
|
@mztariq specifically click the "unwatch" button. |
|
What is the potential impact of Version not being retrieved? Could this affect backwards compatibility with upcoming library updates? EDIT - Nevermind, it only seems to be used for InMemory cache invalidation. |
|
This pull request has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs. |
This PR resolves a critical crash issue in Akavache V11 when initializing on Android devices. The crash occurred during
AkavacheBuilderconstructor execution whenFileVersionInfo.GetVersionInfo()was called with invalid file paths.Problem
On Android,
Assembly.LocationandAppContext.BaseDirectorycan return invalid paths like/Akavache, causing the following crash:This prevents MAUI Android applications from initializing Akavache, making the library unusable on Android in V11.
Solution
Added validation to check if the file exists before calling
FileVersionInfo.GetVersionInfo():Impact
Testing
Fixes #1055.
Warning
Firewall rules blocked me from connecting to one or more addresses (expand for details)
I tried to connect to the following addresses, but was blocked by firewall rules:
definitely-invalid-domain-that-does-not-exist-12345.invalid/home/REDACTED/.dotnet/dotnet exec --runtimeconfig /home/REDACTED/work/Akavache/Akavache/src/Akavache.Tests/bin/Debug/net9.0/Akavache.Tests.runtimeconfig.json --depsfile /home/REDACTED/work/Akavache/Akavache/src/Akavache.Tests/bin/Debug/net9.0/Akavache.Tests.deps.json /home/REDACTED/work/Akavache/Akavache/src/Akavache.Tests/bin/Debug/net9.0/testhost.dll --port 40677 --endpoint 127.0.0.1:040677 --role client --parentprocessid 5019 --telemetryoptedin false(dns block)invalid1.com/home/REDACTED/.dotnet/dotnet exec --runtimeconfig /home/REDACTED/work/Akavache/Akavache/src/Akavache.Tests/bin/Debug/net9.0/Akavache.Tests.runtimeconfig.json --depsfile /home/REDACTED/work/Akavache/Akavache/src/Akavache.Tests/bin/Debug/net9.0/Akavache.Tests.deps.json /home/REDACTED/work/Akavache/Akavache/src/Akavache.Tests/bin/Debug/net9.0/testhost.dll --port 40677 --endpoint 127.0.0.1:040677 --role client --parentprocessid 5019 --telemetryoptedin false(dns block)invalid2.com/home/REDACTED/.dotnet/dotnet exec --runtimeconfig /home/REDACTED/work/Akavache/Akavache/src/Akavache.Tests/bin/Debug/net9.0/Akavache.Tests.runtimeconfig.json --depsfile /home/REDACTED/work/Akavache/Akavache/src/Akavache.Tests/bin/Debug/net9.0/Akavache.Tests.deps.json /home/REDACTED/work/Akavache/Akavache/src/Akavache.Tests/bin/Debug/net9.0/testhost.dll --port 40677 --endpoint 127.0.0.1:040677 --role client --parentprocessid 5019 --telemetryoptedin false(dns block)If you need me to access, download, or install something from one of these locations, you can either:
✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.