Android studio &引用;已配置从属功能,但未设置软件包ID。”;创建新模块时,Android
我正在尝试创建一个新模块。此模块的元素应该对第一个模块可见。这就是为什么我将Android studio &引用;已配置从属功能,但未设置软件包ID。”;创建新模块时,Android,android-studio,android-gradle-plugin,android-module,Android Studio,Android Gradle Plugin,Android Module,我正在尝试创建一个新模块。此模块的元素应该对第一个模块可见。这就是为什么我将实现项目(“: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
实现项目(“: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.android.library”插件。
您可以在模块的build.gradle文件中找到它,将其更改为使用库插件,它应该可以编译。我集成了当前的Reedy答案,强调应用程序和模块必须使用两个不同的插件 如果采用buildSrc方法(强烈建议),则应在中声明两个不同的变量: buildSrc/src/main/java/dependencies.kt
object Plugins {
const val androidApplication = "com.android.application"
const val androidLibrary = "com.android.library"
}
并在app和mymodule build.gradle中正确使用它们
:app
及
:mymodule
plugins {
id(Plugins.androidLibrary)
.........
}
检查您的模块是否为:库而不是应用程序 在build.gradle中检查是否:
'com。安卓库“如果模块是库而不是应用程序 使用
build.gradle中的以下配置(用于模块)
看起来,库不需要应用程序ID非常感谢兄弟,我花了4个小时在这个问题上所有创建的模块都使用
com.android.application
。如果将其重命名为com.android.library
,则会出现以下错误:库项目无法设置applicationId。applicationId在默认配置中设置为“com.example.nameofmodule”。受影响的模块:预期的模块名称
@LeNguyenDuyAnh。从该模块的gradle文件中的defaultConfig中删除applicationId字段。
plugins {
id(Plugins.androidLibrary)
.........
}
plugins {
// id 'com.android.application'
id "com.android.library"
}
android {
defaultConfig {
// applicationId "com.xxx.xx.x"
}
}