A Warning Regarding Android App Startup with Multiprocess Apps

It’s possible to run different components of your Android application in different processes. I’ve avoided multi-process apps because it’s usually unnecessary and it introduces all sorts of pain, but there are certain use cases that require it.

If you’re using multiple processes, then you should be aware that the new AndroidX App Startup library may not work as you expect it to.

App Startup is an easy, efficient way for libraries to initialize themselves (so consumers don’t have to do anything). I recently added it to joda-time-android, but shortly after release someone pointed out that it was no longer working for their app.

It turns out that App Startup only runs on the default process. This is on purpose; the assumption is that you may not want to initialize everything for some random side process that’s just doing a little syncing. Also, it’s technically challenging for a library to know about your other processes. What this means is if you want App Startup to run in other processes, you’re going to have to set it up yourself.

One way to do it is to just add your own InitializationProvider to your process. In AndroidManifest.xml, add:

    tools:node="merge" />

That’s the easy solution that will initialize all libraries using App Startup. If you only need particular libraries for your process, you can initialize them manually:


Many thanks to @Piwai for feedback on this post