droidster droidster - 2 months ago 10
Android Question

How to set the package/applicationId for android instant app?

My project structure contains a base feature module, an installed app module (with free and paid flavors) and an instant app module(only one flavor - free). It seems like the package name for the instant app is coming from the base feature module's manifest.

Why does not the applicationId field in build.gradle of instant app overwrite the package field in the manifest as it does for the installed app?

The same behaviour is also observed in the hello instant app sample.

Answer Source

The base feature module needs to have an application reference to the application module in its dependencies. This allows the base feature to pull in the applicationId from the app module instead of using the one defined in its AndroidManifest.xml.

For example your base feature's build.gradle would look like:

dependencies {
   feature project(':feature1')
   feature project(':feature2')
   application project(':app')

According to the documentation this will build all the flavours (paid & free) and pull in the applicationId for each one.