33

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.

4 Answers 4

55

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.

4
  • Thank you so much bro, I've spent 4 hours stuck in this issue Oct 30, 2020 at 11:47
  • 2
    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, 2020 at 16:21
  • 2
    @LeNguyenDuyAnh that is expected. Remove the applicationId field from defaultConfig in gradle file of that module. Jan 21, 2021 at 9:21
  • But what if I do not have any module? Instead I have only one app module in project, still I am facing same error while building APK.
    – Meet
    Nov 30 at 9:41
12

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

1
  • 1
    This is correct solution, whoever is facing the issue can try this solution
    – Kaunain
    Sep 19 at 8:47
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)
     .........
}
4

Check if your module is : library and not app

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

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.