删除命名空间的包名称时发生 Android 清单合并错误

发布于 2025-01-19 14:50:13 字数 1083 浏览 0 评论 0原文

根据此 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.

但是在这样做后,合并的清单选项卡显示错误,表明我没有提供包装名称。我同时尝试了这两个,但警告构建再次显示。

According to this doc we no longer need to provide package name in AndroidManifest.xml and instead use namespace in build.gradle and there we can define our package name.

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.

But upon doing it the Merged Manifest tab shows error stating that I am not providing a package name. I tried both at the same time but the warning build shows again.

enter image description here

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

满意归宿 2025-01-26 14:50:13

AndroidManifest.xml 文件中的 元素中删除 package="com.your.unique.package.name" 属性您的 app 模块

将其添加到应用程序模块 build.gradle 中,即使用 namespacebuild.gradle(:app)

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

Remove package="com.your.unique.package.name" attribute from the <manifest> element in the AndroidManifest.xml file of your app module

Add it to the app module build.gradle i.e build.gradle(:app) using namespace

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

???? Note: You have to do this for every other module if your project is multi-module.

萌梦深 2025-01-26 14:50:13

从清单中删除软件包元素,然后将其插入§build.gradle§(:app)作为命名空间:

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

Remove package element from manifest and insert it into §build.gradle§(:app) as namespace:

android {
    ...
    ...
    namespace 'your.package.name'
}
饮惑 2025-01-26 14:50:13

上面两个答案都是正确的,但如果您使用任何其他模块,那么也请在那里声明名称空间。我正在使用本机模板模块。

注意:将项目作为文件打开,然后您将看到其他模块或其构建文件。

Above both answers are right but if you are using any other module so please also declare the namespace there. I am using the native templates module.

Note: Open Project as Files then you will see other module or its build file.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文