"Dependent features configured but no package ID was set." 创建新模块时 Android



我正在尝试创建一个新模块。该模块的元素应该对第一个模块可见。这就是为什么我将implementation project(":messanger")添加到Build.gradle(:app),但它给出了以下错误:

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.

您创建的模块正在使用插件"com.android.application",它应该使用"com.andrio.library"插件。您可以在模块的build.gradle文件中找到它,将其更改为使用库插件,它应该进行编译。

我集成了目前的Reedy答案,强调应用程序和模块必须使用两个不同的插件。

如果您转向buildSrc方法(强烈建议(,您应该在中声明两个不同的变量:buildSrc/src/main/java/dependence.kt

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

并在应用程序和mymodule build.gradle 中正确使用它们

:应用

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

:mymodule

plugins {
id(Plugins.androidLibrary)
.........
}

如果模块是库,而不是应用程序

build.gradle ( for the module )中使用以下配置

plugins {
// id 'com.android.application'
id "com.android.library"
}
android {
defaultConfig {
//   applicationId "com.xxx.xx.x"
}
}

看起来,图书馆不需要applicationId

检查您的模块是否为:库而非应用

在build.gradle中,检查是否:com。安卓库的

最新更新