add new resource to SDK addon

5,095 views
Skip to first unread message

dnak

unread,
Jan 20, 2010, 8:34:12 AM1/20/10
to android-porting
Hi, all.

I tried to create SDK addon.
I put mystrings.xml at vendro/sample/frameworks/base/core/res/res/
values.
And, I wrote PRODUCT_PACKAGE_OVERLAYS in sample_addon.mk
So, I did below command.

$ make PRODUCT-sample_addon-sdk_addon

But, below error ocuured and make stopped.

Resource at foo appears in overlay but not in the base package; use
<add-resource> to add.

What error?
I did not found informations about this error on web.
Are there someone who have same problem?

Below is mystrings.xml.

------------------
<?xml version="1.0" encoding="utf-8"?>
<resources xmlns:xliff="urn:oasis:names:tc:xliff:document:1.2">
<string name="foo">Hello World</string>
</resources>
------------------

Regards.

Dianne Hackborn

unread,
Jan 20, 2010, 4:25:21 PM1/20/10
to android...@googlegroups.com
Your overlay is introducing a new resource into the platform that doesn't already exist.  As the error message says, you need to use <add-resource> to tell it this is okay.




--
Dianne Hackborn
Android framework engineer
hac...@android.com

Note: please don't send private questions to me, as I don't have time to provide private support, and so won't reply to such e-mails.  All such questions should be posted on public forums, where I and others can see and answer them.

dnak

unread,
Jan 23, 2010, 11:14:30 AM1/23/10
to android-porting
Thank you for your reply.

I want to know how to use <add-resource>, but I didn't find the
information about <add-resource>.
So, I read aapt's source, and I guessed how to use <add-resource>
.
I wrote below code to string.xml.

<add-resource type="string" name="foo">Hello World</add-resource>

Building string.xml was procceeded.
Is is correctly?

By the way, where is the information about resource xml tag (e.g. <add-
resource>)?
I don't want to read aapt's source further, whenever an error
happening.

Regards.

Dianne Hackborn

unread,
Jan 23, 2010, 8:47:41 PM1/23/10
to android...@googlegroups.com
Yeah looks fine.  I think currently the only information about this is in the aapt source.


Regards.

cneth

unread,
Feb 18, 2010, 8:49:28 AM2/18/10
to android-porting
I believe the <add-resource> is used _only_ to introduce the new
resource; you can't simultaneously declare it also.

I.e. you need to do this:

<add-resource type="string" name="foo"></add-resource>
<string name="foo">Hello</string>

From what I can see, aapt throws away everything but the name and type
attributes in the <add-resource> tag.
This makes sense because otherwise the <add-resource> tag would need
to be able to describe every other possible resource.

Craig

On Jan 23, 8:47 pm, Dianne Hackborn <hack...@android.com> wrote:
> Yeah looks fine.  I think currently the only information about this is in
> the aapt source.
>
>
>
> On Sat, Jan 23, 2010 at 8:14 AM, dnak <newvf91.brjtn579...@gmail.com> wrote:
> > Thank you for your reply.
>
> > I want to know how to use <add-resource>, but I didn't find the
> > information about <add-resource>.
> > So, I read aapt's source, and I guessed how to use <add-resource>
> > .
> > I wrote below code to string.xml.
>
> > <add-resource type="string" name="foo">Hello World</add-resource>
>
> > Building string.xml was procceeded.
> > Is is correctly?
>
> > By the way, where is the information about resource xml tag (e.g. <add-
> > resource>)?
> > I don't want to read aapt's source further, whenever an error
> > happening.
>
> > Regards.
>
> > --

> > unsubscribe: android-porti...@googlegroups.com<android-porting%2Bunsu...@googlegroups.com>


> > website:http://groups.google.com/group/android-porting
>
> --
> Dianne Hackborn
> Android framework engineer

> hack...@android.com

Dianne Hackborn

unread,
Feb 18, 2010, 2:49:41 PM2/18/10
to crai...@gmail.com, android-porting
Yeah add-resource is just to tell aapt that it is okay for this to be introduced as a new resource even though it doens't already exist.




--
Dianne Hackborn
Android framework engineer
hac...@android.com
Reply all
Reply to author
Forward
0 new messages