Skip to content

fix(android): validate external files dir and mkdirs() for model download/import#569

Open
jonathanrao99 wants to merge 1 commit intogoogle-ai-edge:mainfrom
jonathanrao99:main
Open

fix(android): validate external files dir and mkdirs() for model download/import#569
jonathanrao99 wants to merge 1 commit intogoogle-ai-edge:mainfrom
jonathanrao99:main

Conversation

@jonathanrao99
Copy link
Copy Markdown

Summary

Improves directory creation handling for model downloads and imports on Android.

Changes

  • Added null checks for getExternalFilesDir(null)
  • Validated mkdirs() instead of assuming success
  • Added clearer error messages when directory creation fails

Why

Previously, the app continued after directory creation failed, leading to a vague "folder not found" error later in the process. This change fails early and provides clearer feedback.

Notes

This improves behavior on newer Android versions (including Android 16 QPR2) by handling storage access more defensively.

Closes #553

@google-cla
Copy link
Copy Markdown

google-cla Bot commented Apr 5, 2026

Thanks for your pull request! It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA).

View this failed invocation of the CLA check for more information.

For the most up to date status, view the checks section at the bottom of the pull request.

Copy link
Copy Markdown
Author

@jonathanrao99 jonathanrao99 left a comment

Choose a reason for hiding this comment

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

Hi! This PR adds defensive handling for directory creation during model download/import.

  • Checks for null getExternalFilesDir(null)
  • Validates mkdirs() instead of assuming success
  • Fails early with clearer error messages

This addresses the "folder not found" issue reported on Android 16 QPR2 by preventing silent directory creation failures and surfacing the root cause earlier.

@jonathanrao99
Copy link
Copy Markdown
Author

Hi! I've now signed the Google CLA. Please let me know if everything looks good or if any further changes are needed. Thanks!

@dpknag dpknag mentioned this pull request Apr 7, 2026
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.

Folder not found

1 participant