Android Instant App : Feature module : The module cannot be android library

1.5k views Asked by At

I started converting my app to support instant feature, following the Google IO tutorial. I got the build running correctly. I've disabled aapt2 and enableNewResourceProcessing as i was running into build errors. The module builds without errors after disabling those two flags but when i go to edit configuration of the base Feature of the app i get The module cannot be android library.

Does anyone know what causes this issue. I'm using com.android.feature plugin in the feature module's build along with build flavours and build types.

3

There are 3 answers

0
Sandeep Chauhan On

A feature module is treated as a library. It doesn't have an application ID. So, "The module cannot be android library" error is generated.

0
Zon On

Don't run your feature. Run your instantapp instead and set feature URL in it:

Run -> Edit Configurations -> Android App -> instantapp -> General -> Launch Options -> Launch = URL -> URL = https://example.com/my_feature

0
BruceWayne On

The problem I was facing was that there was a build configuration for the instant feature as well. Since each instant feature is considered as an android library, Studio throws errors saying module cannot be android library. To solve this i simply removed the build configuration via

Run -> Edit configuration -> Click on - button

Keep your base app module configuration and delete all other feature configurations.