Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Conversation

Copy link
Contributor

Copilot AI commented Sep 6, 2025

This PR resolves a critical crash issue in Akavache V11 when initializing on Android devices. The crash occurred during AkavacheBuilder constructor execution when FileVersionInfo.GetVersionInfo() was called with invalid file paths.

Problem

On Android, Assembly.Location and AppContext.BaseDirectory can return invalid paths like /Akavache, causing the following crash:

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)

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():

// Additional validation before calling FileVersionInfo.GetVersionInfo to prevent Android crashes
if (!string.IsNullOrWhiteSpace(fileLocation) && File.Exists(fileLocation))
{
    var fileVersionInfo = FileVersionInfo.GetVersionInfo(fileLocation);
    Version = new(fileVersionInfo.ProductMajorPart, fileVersionInfo.ProductMinorPart, 
                  fileVersionInfo.ProductBuildPart, fileVersionInfo.ProductPrivatePart);
}

Impact

  • Fixes Android crashes when initializing Akavache in MAUI applications
  • Maintains backward compatibility - no breaking changes
  • Minimal code change - surgical fix with only 6 lines modified
  • Graceful degradation - if version info can't be determined, the builder continues without it

Testing

  • ✅ All existing tests (776) continue to pass
  • ✅ Added comprehensive Android initialization test suite
  • ✅ Verified MAUI sample builds successfully for Android
  • ✅ Tested with invalid file paths to ensure graceful handling

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
    • Triggering command: /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
    • Triggering command: /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
    • Triggering command: /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.

Copilot AI changed the title [WIP] [Bug]: New V11 crashes on Android with File Not Found Exception Fix Android FileNotFoundException crash in AkavacheBuilder constructor Sep 6, 2025
Copilot AI requested a review from glennawatson September 6, 2025 13:59
Copilot finished work on behalf of glennawatson September 6, 2025 13:59
@glennawatson glennawatson marked this pull request as ready for review September 6, 2025 14:00
@glennawatson glennawatson enabled auto-merge (squash) September 6, 2025 14:01
@glennawatson glennawatson merged commit bc36427 into main Sep 6, 2025
1 of 2 checks passed
@glennawatson glennawatson deleted the copilot/fix-1055 branch September 6, 2025 14:36
@codecov
Copy link

codecov bot commented Sep 6, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 0.00%. Comparing base (8adce72) to head (1c633e2).
⚠️ Report is 1 commits behind head on main.

Additional details and impacted files
@@     Coverage Diff      @@
##   main   #1110   +/-   ##
============================
============================

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@mztariq
Copy link

mztariq commented Sep 6, 2025 via email

@glennawatson
Copy link
Contributor

@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.

@glennawatson
Copy link
Contributor

@mztariq specifically click the "unwatch" button.

@Picao84
Copy link

Picao84 commented Sep 9, 2025

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.

@github-actions
Copy link

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.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Sep 24, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: New V11 crashes on Android with File Not Found Exception

5 participants