【问题标题】:Android Manifest merge error when removing package name for namespace删除命名空间的包名称时Android清单合并错误
【发布时间】:2022-10-16 19:20:40
【问题描述】:

根据doc,我们不再需要在 AndroidManifest.xml 中提供包名,而是在 build.gradle 中使用命名空间,我们可以在那里定义我们的包名。

package="org.sample.domain" found in source AndroidManifest.xml: C:\Users\user\Desktop\Projects\Sample\app\libs\sample\src\main\AndroidManifest.xml.
Setting the namespace via a source AndroidManifest.xml's package attribute is deprecated.
Please instead set the namespace (or testNamespace) in the module's build.gradle file, as described here: https://developer.android.com/studio/build/configure-app-module#set-namespace
This migration can be done automatically using the AGP Upgrade Assistant, please refer to https://developer.android.com/studio/build/agp-upgrade-assistant for more information.

但在这样做的时候合并清单选项卡显示错误,指出我没有提供包名称。我同时尝试了两者,但警告版本再次显示。

【问题讨论】:

  • 在该文档上,没有一行说明您可以从清单文件中完全排除包属性。您的 Merged Manifest 包属性可能会根据命名空间或 applicationId 而更改,但它并未声明要一起删除包属性。
  • @nitinkumarp 如果包属性已被弃用,它的替代品是什么?
  • @nitinkumarp 是的,但 Gradle 构建抱怨它很奇怪
  • 您可以在此处添加该错误吗?

标签: android android-studio android-gradle-plugin android-manifest


【解决方案1】:

从清单中删除包元素并将其作为命名空间插入到 build.gradle(:app) 中:

{android
 ...
 ...
 namespace 'your package name'
}

【讨论】:

    猜你喜欢
    • 2022-01-04
    • 1970-01-01
    • 2019-06-27
    • 1970-01-01
    • 2019-12-13
    • 2018-03-06
    • 1970-01-01
    • 2018-12-13
    • 2016-12-18
    相关资源
    最近更新 更多