29

I am trying to create a new module. Elements of this module should be visible to the first module.That is why I add implementation project(":messanger") to Build.gradle(:app) but it gives the following error:

Dependent features configured but no package ID was set.
Execution failed for task ':app:processDebugResources'.
A failure occurred while executing 
com.android.build.gradle.internal.tasks.Workers$ActionFacade
AAPT2 aapt2-4.0.0-beta01-6051327-linux Daemon #0: Unexpected error during link, attempting 
 to 
stop daemon.
 This should not happen under normal circumstances, please file an issue if it does.
Nurseyit Tursunkulov
  • 8,012
  • 12
  • 44
  • 78

4 Answers4

50

The module you have created is using the plugin 'com.android.application' and it should be using the 'com.android.library' plugin. You can find this in the build.gradle file in your module, change this to use the library plugin and it should compile.

Reedy
  • 1,866
  • 2
  • 20
  • 23
  • Thank you so much bro, I've spent 4 hours stuck in this issue – Mouaad Abdelghafour AITALI Oct 30 '20 at 11:47
  • 1
    All created modules use `com.android.application`. If I rename it to `com.android.library` I get this error: `Library projects cannot set applicationId. applicationId is set to 'com.example.nameOfMyModule' in default config. Affected Modules: nameOfMyModule` – Sorry Nov 16 '20 at 16:21
  • 1
    @LeNguyenDuyAnh that is expected. Remove the applicationId field from defaultConfig in gradle file of that module. – Rahul Thakur Jan 21 '21 at 09:21
9

I integrate the present Reedy answer, stressing that two different plugins must be used for app and modules.

if you move to a buildSrc approach (highly suggested) you should declare two different variables in: buildSrc/src/main/java/dependencies.kt

object Plugins {

   const val androidApplication    = "com.android.application"
   const val androidLibrary        = "com.android.library"
}

and use them properly in app and mymodule build.gradle

:app

plugins {
    id(Plugins.androidApplication)
     .......

}

and

:mymodule

plugins {
    id(Plugins.androidLibrary)
     .........
}
albaspazio
  • 121
  • 1
  • 6
9

If the module is an library , not an application

use the following configuration in build.gradle ( for the module )

plugins {
    // id 'com.android.application'
    id "com.android.library"
}

android {
    defaultConfig {
     //   applicationId "com.xxx.xx.x"
    }
}

It seems like that , the library did not need an applicationId

dengST30
  • 3,643
  • 24
  • 25
4

Check if your module is : library and not app

in build.gradle check if : 'com. android. library'