Skip to content

fix: ensure dex cache directory exists before proxy generation#1938

Open
NathanWalker wants to merge 1 commit intomainfrom
fix/dex-cache-existence-check
Open

fix: ensure dex cache directory exists before proxy generation#1938
NathanWalker wants to merge 1 commit intomainfrom
fix/dex-cache-existence-check

Conversation

@NathanWalker
Copy link
Copy Markdown
Contributor

Summary

  • Hardens dex cache directory setup to verify the directory exists and is writable after mkdirs(), falling back to files/secondary-dexes if code_cache/secondary-dexes is unusable
  • Adds defensive mkdirs() in ProxyGenerator.saveProxy() before createNewFile() as a safety net

Context

ProxyGenerator.saveProxy() calls File.createNewFile() which fails with ENOENT when the parent directory is missing. The runtime constructs the dex cache path manually (<dataDir>/code_cache/secondary-dexes) rather than using Context.getCodeCacheDir(), and while DexFactory calls mkdirs() at init time, it never checks the return value.

On newer Android versions (API 28+), the OS can clear code_cache to reclaim storage, and stricter permission models can cause mkdirs() to silently fail. This was always fragile but rarely triggered on older Android versions where code_cache was reliably present.

Harden dex directory setup in RuntimeHelper with existence check and fallback to files/secondary-dexes when code_cache is unavailable. Add defensive parent directory creation in ProxyGenerator.saveProxy() to prevent ENOENT crashes on newer Android versions.
@NathanWalker NathanWalker requested a review from triniwiz April 9, 2026 15:49
@NathanWalker
Copy link
Copy Markdown
Contributor Author

Tagged rc with 9.0.3-rc.0 for evaluation.

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.

2 participants