Why do I have more than one Application instance?
summary
App instances duplicate across processes when merged manifests from libraries declare components with a process attribute, causing secondary processes to fork and call onCreate; this produced SQLite error code 5 by concurrent access. Solution: compare current process name to package name (Android P has getProcessName; older versions read {/proc/PID/cmdline}) and only run heavy init in the main process. Also available: a small library to detect the primary process and a Gradle plugin that catches unexpected changes in the merged manifest.
AI-written summary · about
chapters (12)
- 0:00Introduction and welcome
- 1:07Application class misconception
- 3:13Debugging the SQLite error
- 5:20Why multiple processes exist
- 7:12Process names in Android
- 9:47Detecting main process
- 11:14Getting process name
- 13:22Handling secondary processes
- 14:07Key takeaways
- 14:28Libraries for process checks
- 14:50Gradle plugin for manifest changes
- 15:56Closing and Q&A
related talks
32mInside Android: Context, Binder IPC, Zygote
47mMonolithic application, it's not automatic
42mAndroid Internals for Developers
43mAndroid Internals for Developers
31mI have no idea what my app is doing ¯\_(ツ)_/¯ - Protecting your application from unintended side eff
40mAndroid Internals
27mBuild effective OEM-level apps on Android Things
50mBirth, Life and Death, or What Happens to an App in the System
