Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to reference an icon from a Library Project in Application's 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?

like image 541
an00b Avatar asked Jun 13 '11 18:06

an00b


People also ask

Where can you define the icon for your activity?

Icon for an Activity is defined in the manifest file.

What is AndroidManifest XML file what are its tags?

Every project in Android includes a Manifest XML file, which is AndroidManifest. xml, located in the root directory of its project hierarchy. The manifest file is an important part of our app because it defines the structure and metadata of our application, its components, and its requirements.

What is AndroidManifest XML and what should we include in it?

The AndroidManifest. xml file contains information of your package, including components of the application such as activities, services, broadcast receivers, content providers etc.


2 Answers

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...

like image 102
Snicolas Avatar answered Oct 25 '22 04:10

Snicolas


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.

like image 38
Spoetnic Avatar answered Oct 25 '22 03:10

Spoetnic