Skip to content

fix(android): FileNotFoundException after application cache got cleared#1922

Merged
Gustl22 merged 6 commits into
bluefireteam:mainfrom
krispypen:patch-1
Jan 23, 2026
Merged

fix(android): FileNotFoundException after application cache got cleared#1922
Gustl22 merged 6 commits into
bluefireteam:mainfrom
krispypen:patch-1

Conversation

@krispypen

Copy link
Copy Markdown
Contributor

Description

When an android device is low on storage, it can happen that the OS clears the cache of the app. In that case we get a FileNotFoundException when running an audio file for the 2nd time.

Checklist

  • The title of my PR starts with a Conventional Commit prefix (fix:, feat:, refactor:,
    docs:, chore:, test:, ci: etc).
  • I have read the Contributor Guide and followed the process outlined for submitting PRs.
  • I have updated/added tests for ALL new/updated/fixed functionality.
  • I have updated/added relevant documentation and added dartdoc comments with ///, where necessary.
  • I have updated/added relevant examples in example.

Breaking Change

  • Yes, this is a breaking change.
  • No, this is not a breaking change.

Related Issues

@krispypen

Copy link
Copy Markdown
Contributor Author

@Gustl22 can you have a look? 🙏

@Gustl22

Gustl22 commented Jun 5, 2025

Copy link
Copy Markdown
Collaborator

Thank you for the contribution and sorry for the delay!

if (!loadedFiles.containsKey(fileName) ||
// the file can be removed from the cache, this
// can happen automatically when the storage is almost full
(!kIsWeb && !fileSystem.file(loadedFiles[fileName]).existsSync())) {

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would prefer to check also check for if defaultTargetPlatform == Platform.Android, if it's something that only occurs on android.

I would also prefer to use await exists to not block the thread.

Also do you have some reference (preferably of Android) we can add to the docs here?

@spydon

spydon commented Aug 26, 2025

Copy link
Copy Markdown
Member

@krispypen are you planning on finishing up this PR? :)

@krispypen

krispypen commented Aug 26, 2025

Copy link
Copy Markdown
Contributor Author

@krispypen are you planning on finishing up this PR? :)

Oh I missed the previous message, I'll update today! @spydon

@krispypen

Copy link
Copy Markdown
Contributor Author

@spydon @Gustl22 I don't think these failing tests are something to do with this change

@spydon

spydon commented Aug 27, 2025

Copy link
Copy Markdown
Member

@spydon @Gustl22 I don't think these failing tests are something to do with this change

They don't indeed, we are looking into them. :)
Thanks for updating the PR!

@callmephil

Copy link
Copy Markdown

@spydon, do you happen to have any updates on this?

@spydon spydon left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Lgtm, can we merge this @Gustl22 ?

@Gustl22 Gustl22 changed the title fix: FileNotFoundException after application cache got cleared fix(android): FileNotFoundException after application cache got cleared Jan 22, 2026

@Gustl22 Gustl22 left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM haven't tested though. Thank you for the patience!

@Gustl22 Gustl22 merged commit 0e3bca2 into bluefireteam:main Jan 23, 2026
50 of 52 checks passed
@moodstubos

Copy link
Copy Markdown

@Gustl22
Can the fix also uploaded to pub.dev please ?

Thx

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Sound not found inside cache folder - app crash

5 participants