5

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.

BruceWayne
  • 491
  • 1
  • 4
  • 12
  • What is the value of `apply plugin [..]` in your module level build.gradle? – pRaNaY May 30 '17 at 10:31
  • `com.android.feature` – BruceWayne May 30 '17 at 11:33
  • Are you using build tools 26.0.0-rc1 or above? Also, you'll need to use aapt2. Can you tell what errors did you see with aapt2? – Anirudh May 30 '17 at 16:49
  • I've changed to 26 but no success. I was using 25. With aapt2 i get ` uncompiled XML file passed as argument. Must be compiled first into .flat file.` The stacktrace is too big but `Caused by: java.util.concurrent.ExecutionException: com.android.builder.internal.aapt.AaptException: AAPT2 link failed:` and `ERROR: failed parsing overlays` are the prominant error messages – BruceWayne May 31 '17 at 06:14
  • Should i ask a question for aapt2 error ? – BruceWayne May 31 '17 at 06:57
  • I removed the build configuration for feature all together ... it was my mistake ... while make the app instant enabled i have refactored and accidentally removed launcher activity. Its working fine now ... Guess i should delete the question ? – BruceWayne Jun 02 '17 at 05:00
  • 1
    You could answer your own question and then mark the answer as resolved. – Arun Venkatesan Jun 02 '17 at 20:38
  • @BruceWayne can you give me more details? I'm experiencing this issue and I haven't found any solutions for it. Submit your solution as a detailed answer so other users + me can see what have you done to fix this issue. Thanks :) – Arda Çebi Feb 04 '18 at 11:58
  • @ArdaÇebi submitted the solution – BruceWayne Feb 05 '18 at 10:24

3 Answers3

-1

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.

Sandeep Chauhan
  • 117
  • 1
  • 9
-1

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.

BruceWayne
  • 491
  • 1
  • 4
  • 12
-1

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

Zon
  • 18,610
  • 7
  • 91
  • 99