0

I have an Instant app with following modules:

  • base feature
  • feature1
  • feature2
  • installed
  • instant

I want installed to have both feature1 and feature2, and instant only have feature1.

Instant build.gradle:

apply plugin: 'com.android.instantapp'

dependencies {
    implementation project(':base')
    implementation project(':feature1')
}

Installed build.gradle:

apply plugin: 'com.android.application'

dependencies {
    implementation project(':base')
    implementation project(':feature1')
    implementation project(':feature2')
}

I want to test upload to Google Play developer console, so I created instant app release build. It contains base and feature1 apks, but when I upload it to console I get the error:

Your Instant App APKs contains an APK name 'feature2' that either does not exist or was not included.

What am I doing wrong? It is possible to have different sets of features for installed and instant apps, right?

mol
  • 2,607
  • 4
  • 21
  • 40
  • implementation project(':feature1') implementation project(':feature2'). There is a bug in the tools that ignores the numbers in the feature name so both features end up being "feature". This can cause some issues. Use proper names for the features . for e.g "listing_feature", "details_feature" – Anirudh Jun 10 '17 at 01:34
  • @Anirudh Thanks, but these names are just for example. Features have proper names in my project. – mol Jun 10 '17 at 09:51

2 Answers2

1

It is possible to have different sets of features for installed and instant apps, right?

Yes it should be possible. Although you can use the com.android.library plugin for feature2 if it's only used as an AAR file by your installed app (in fact, doing that may help reveal the issue).

What am I doing wrong?

I'm not sure but I'm guessing that feature2 is somehow being referenced by one of the Instant App APK files. To check, load the Instant App .zip file in APK Analyzer in Studio 3.0 Canary, then look inside the AndroidManifest.xml file of each of your APKs. Look for an attribute in your <activity> that is set something like this: android:splitName="feature2". This tells one APK that the code for the other feature exists in another feature APK.

The error sounds like it found a reference to feature2 but not corresponding APK file in the Instant App zip.

If this is the case, then you should check your build.gradle files again as well as your AndroidManifest.xml in each module to make sure there are no references to feature2 that the instant module may pick up.

AdamK
  • 21,199
  • 5
  • 42
  • 58
  • Thanks for response. Indeed there are all Activities from `feature2` with `split="feature2"` in `base` merged `AndroidManifest.xml`. But I inspected all modules and seems like nothing references `feature2`. Do you have any ideas why `feature2` Activities are added to instant app manifest? – mol Jun 10 '17 at 10:50
  • I'm not sure how that could happen. You could run a verbose `gradlew assembleDebug` from command line targeting your instant app module to see how it merges/combines all the modules. You can also try switching `feature2` to the `com.android.library` plugin which may help. Otherwise it sounds like there might be a bug here. If you can recreate a sample project that reproduces then I would file a bug as per: https://developer.android.com/studio/report-bugs.html – AdamK Jun 11 '17 at 00:23
0

The instant app should have all the feature modules even though you don't want to use them just don't link them with a url and they will never be loaded.

The play store downloads base + feature1 when an instant app is called. Now, suppose your feature1 is linked to feature2 through deep links then play store downloads feature2. The instant app should contain all the feature apks in the zip.

Add this in your build gradle and then try to upload. This worked for me.

implementation project(':feature2')

Sandeep Chauhan
  • 117
  • 1
  • 9
  • The thing is `feature2` module is very big and I'm afraid that apk will not pass 4Mb validation, so I want to exclude it from instant app. I also tried to exclude `feature1` from instant and have it in installed and it worked fine, so apparentely instant and installed can have different sets of modules. – mol Jun 15 '17 at 08:30