如何在应用程序的 AndroidManifest.xml 中引用库项目中的图标

发布于 2024-11-15 06:09:02 字数 844 浏览 6 评论 0原文

我试图对从图书馆项目派生的所有应用程序使用相同的应用程序图标。

我认为这就像实施提供的建议一样简单 在此线程中,但不幸的是它不起作用。

我所做的是将以下行添加到应用程序的 AndroidManifest.xml 中的 标记中:

xmlns:mylib="http://schemas.android.com/apk/res/com.example.baseapp"

在同一 AndroidManifest.xml< /code> 文件,将典型的 @drawable/icon 更改为:

   <application android:icon="@mylib:drawable/icon">

但它不起作用!

相反,Eclipse 告诉我:

错误:错误:找不到资源 与给定名称匹配(在“图标”处) 值“@omlib:drawable/icon”)。

显然,从布局 XML 和清单 XML 引用可绘制对象是不同的。

如何在应用程序的 AndroidManifest.xml 中引用库项目中的图标?

I am trying to use the same application icon for all applications derived from a Library Project.

I thought that it would be as simple as implementing the advice provided in this thread, but unfortunately it doesn't work.

What I did is add to the <manifest> tag in the application's AndroidManifest.xml the following line:

xmlns:mylib="http://schemas.android.com/apk/res/com.example.baseapp"

And a few lines down the same AndroidManifest.xml file, change the typical @drawable/icon to:

   <application android:icon="@mylib:drawable/icon">

But it doesn't work!

Instead, Eclipse tells me that:

error: Error: No resource found that
matches the given name (at 'icon' with
value '@omlib:drawable/icon').

Apparently, referencing drawables from a layout XML and the manifest XML are not the same.

How do I reference an icon from a Library Project in Application's AndroidManifest.xml?

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

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

发布评论

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

评论(2

叫思念不要吵 2024-11-22 06:09:02

您是否尝试仅使用可绘制/图标?我不知道你的设置,但它对我有用。

也许在一个好的项目和库清理之后......

Did you try with drawable/icon only ? I don't know about your setup but it works for me.

Perhaps after a good project and librairy clean up...

倾听心声的旋律 2024-11-22 06:09:02

对于仍在阅读本文的人:
我相信这个问题从 SDK17 开始就被修复了。

您应该编写以下内容:

xmlns:mylib="http://schemas.android.com/apk/res-auto"

这应该使您也能够引用图书馆项目中的资源。

For people still reading this:
I believe this was fixed since SDK17.

you should write the following:

xmlns:mylib="http://schemas.android.com/apk/res-auto"

This should enable you to reference resources from library projects as well.

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