0

I struggle to define a good instant app architecture for my app. Currently the app is in an old style instant app structure. Right now I am converting it to dynamic modules. So far i have it working for the installable version. But I struggle to get the instant features working, because I don't know how to properly define an entry point. The app is single activity only and uses deeplinks to navigate. In the old instant app architecture I used to put in each feature module a seperate manifest.xml with its own activity. The installable module had something similar. Now with dynamic modules you have to point from the base manifest.xml to one single activity which should also be located in the same base module.

But this is not what I want. The installable activity is a lot different than the instant app one.

I have currently the following modules:

  • Base
  • Combined
  • Feature_A
  • Feature_B
  • Feature_C

The combined module is basically the installable version of the app. It includes all the features modules and has one single activity. It also contains lots of extra functionality which is not needed in any feature module. Feature modules are just fragments and logic. Base module contains all shared logic.

Now I have the following questions:

  1. Within the manifest.xml in the base module, the default activity has to be defined. It is right now pointing to my combined (installable) module's activity. Idealy for instant apps i want to have a different default activity. Is this possible?

  2. I can create an activity inside the base module. But from there i cannot reach any class / activity in any module. So it is not an option to create an intermediate activity in the base module and from there, depending if its an instant or installed, load the right activity. How to deal with this?

  3. Do I need to add entry points (url intent filters) in the base manifest or in each dynamic module?

petezurich
  • 9,280
  • 9
  • 43
  • 57
Gillis Haasnoot
  • 2,229
  • 1
  • 19
  • 23

2 Answers2

0

First, let me introduce you to blog: A simpler experience for instant apps, Create an instant-enabled app bundle and About Android App Bundles

dist:onDemand | dist:instant

  • false | true = instant-app module, will also be included in installed-app
  • false | false = installed-only module
  • true | false = "on-demand" installed-only module

Second, in the new model, you'll notice that com.android.application is now the "base". Ok, easy, your "old base", that was once a com.android.feature, will now be all inside com.android.application (confusing at first, but this is now essentially acting like a library module?? yep!)

Ok, I'm assuming your "Combined" used to be the com.android.application module? You can put that into a dynamic-feature module: false | false (installed), this will confine it to the installed-app.

Your "Feature_X" modules, previously your non-base com.android.feature modules, can now all each be a dynamic-feature module enabled for instant: false | true (instant).

Now, default activity is still the same for you, I think. Your installed-app's MainActivity is in "Combined", right? And Instant Apps has always relied on the location of the default-url for its Try Now, wherever you set that. So, I think this is still the same for you?

The "cannot reach" issue now is that none of these modules see each other, except base/application sitting at the root. Unlike before, Combined/app could at least see all the features as libraries. Now, you'll need resort to calling them by their class name or by their intent-filter/urls or etc..

Entry points? It should be a similar setup as before:

  • As installed-app: base + combined + a + b + c
  • As instant-app: base + (a , b , c)

But did I misread? Your current old-model feature modules contain only "fragments" for your MainActivity? No activity of their own or an individual activity per to hold each one? (Then as an installed-app, those activities would be ignored, and only the fragments would be collected for the single installed-app's activity?)

In any case, you could also look into exploring SplitInstall to use while as an instant app. (yes, you can also use this split install on instant modules)

TWL
  • 6,228
  • 29
  • 65
0
  1. Within the manifest.xml in the base module, the default activity has to be defined. It is right now pointing to my combined (installable) module's activity. Idealy for instant apps i want to have a different default activity. Is this possible?

please check this post for how to define entry point in instant module and launch the base module activity and instant experience respectively.

How to include instant dynamic feature module in instant app?

Jitendra
  • 52
  • 8