Account Options

  1. Sign in
The old Google Groups will be going away soon, but your browser is incompatible with the new version.
Google Groups Home
« Groups Home
custom attributes in library projects
There are currently too many topics in this group that display first. To make this topic appear first, remove this option from another topic.
There was an error processing your request. Please try again.
flag
  Messages 1 - 25 of 28 - Collapse all  -  Translate all to Translated (View all originals)   Newer >
The group you are posting to is a Usenet group. Messages posted to this group will make your email address visible to anyone on the Internet.
Your reply message has not been sent.
Your post was successful
 
From:
To:
Cc:
Followup To:
Add Cc | Add Followup-to | Edit Subject
Subject:
Validation:
For verification purposes please type the characters you see in the picture below or the numbers you hear by clicking the accessibility icon. Listen and type the numbers you hear
 
Vladimir Lebedev-Schmidthof  
View profile  
 More options Jul 8 2010, 6:27 am
From: Vladimir Lebedev-Schmidthof <dair....@gmail.com>
Date: Thu, 8 Jul 2010 03:27:12 -0700 (PDT)
Local: Thurs, Jul 8 2010 6:27 am
Subject: custom attributes in library projects
Hello,

Having custom attribute (in attrs.xml) in library project leads to
compilation fail of the project dependent of that library.

I.e.:
MyLib project (library)

AndroidManifest.xml:
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
      package="com.mycompany.test.lib"
      android:versionCode="1"
      android:versionName="1.0">
...
</manifest>

res/layout/main.xml:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/
android"
        xmlns:my="http://schemas.android.com/apk/res/
com.mycompany.test.lib"
    android:orientation="vertical"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    >
<com.mycompany.test.lib.MyWidget
    android:id="@+id/my_widget"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    my:customValue="324"/>
</LinearLayout>

res/values/attrs.xml:
<resources>
        <declare-styleable name="MyWidget">
                <attr name="customValue" format="integer"/>
        </declare-styleable>
</resources>

And there are nothing in TestApp except AndroidManifest.xml:
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
      package="com.mycompany.test.app"
      android:versionCode="1"
      android:versionName="1.0">
...
</manifest>

And aapt says that
res/layout/main.xml:13: error: No resource identifier found for
attribute 'customValue' in package 'com.mycompany.test.lib'

How to avoid this except for no having custom attributes in library?


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Xavier Ducrohet  
View profile  
 More options Jul 9 2010, 2:18 pm
From: Xavier Ducrohet <x...@android.com>
Date: Fri, 9 Jul 2010 11:18:22 -0700
Local: Fri, Jul 9 2010 2:18 pm
Subject: Re: [android-developers] custom attributes in library projects
Ah, there's a problem with the namespace.

From aapt's point of view all the resources are compiled for the
package name of the application (com.mycompany.test.app in your case),
so your "customValue" attribute is defined in that namespace, and not
in the namespace of the library.

At this time, the only solution is to remove the layout from the
library and move it into the apps and edit the namespace to match the
application package.

We'll look at fixing this.
xav

On Thu, Jul 8, 2010 at 3:27 AM, Vladimir Lebedev-Schmidthof

--
Xavier Ducrohet
Android SDK Tech Lead
Google Inc.

Please do not send me questions directly. Thanks!


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
RCASTO  
View profile  
 More options Aug 17 2010, 12:57 pm
From: RCASTO <casto.rob...@gmail.com>
Date: Tue, 17 Aug 2010 09:57:25 -0700 (PDT)
Local: Tues, Aug 17 2010 12:57 pm
Subject: Re: custom attributes in library projects
Were you able to find a work around to this problem?

On Jul 8, 6:27 am, Vladimir Lebedev-Schmidthof <dair....@gmail.com>
wrote:


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Clément Plantier  
View profile  
 More options Aug 20 2010, 8:04 am
From: Clément Plantier <clemplant...@gmail.com>
Date: Fri, 20 Aug 2010 05:04:14 -0700 (PDT)
Local: Fri, Aug 20 2010 8:04 am
Subject: Re: custom attributes in library projects
Any update about this problem?

On Jul 9, 8:18 pm, Xavier Ducrohet <x...@android.com> wrote:


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Tom  
View profile  
 More options Sep 15 2010, 1:58 am
From: Tom <tom.broadb...@gmail.com>
Date: Tue, 14 Sep 2010 22:58:30 -0700 (PDT)
Local: Wed, Sep 15 2010 1:58 am
Subject: Re: custom attributes in library projects

i'm also hitting this issue.  can't create a xml-configurable custom
view in a library project..

is there a bug filed on this already?  is there an ETA for a fix?

thanks

On Aug 20, 5:04 am, Clément Plantier <clemplant...@gmail.com> wrote:


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Open  
View profile  
 More options Nov 9 2010, 1:01 am
From: Open <gro...@tenromans.com>
Date: Mon, 8 Nov 2010 22:01:19 -0800 (PST)
Local: Tues, Nov 9 2010 1:01 am
Subject: Re: custom attributes in library projects
Same problem here.

On Sep 14, 9:58 pm, Tom <tom.broadb...@gmail.com> wrote:


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Leif  
View profile  
 More options Nov 23 2010, 1:13 pm
From: Leif <l...@leifrilbe.com>
Date: Tue, 23 Nov 2010 10:13:03 -0800 (PST)
Local: Tues, Nov 23 2010 1:13 pm
Subject: Re: custom attributes in library projects
And same here too...

On 9 Nov, 07:01, Open <gro...@tenromans.com> wrote:


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
schwiz  
View profile  
 More options Dec 28 2010, 2:08 am
From: schwiz <sch...@gmail.com>
Date: Mon, 27 Dec 2010 23:08:38 -0800 (PST)
Local: Tues, Dec 28 2010 2:08 am
Subject: Re: custom attributes in library projects
Arrrrg!! hopefully a hot fix soon??

On Nov 23, 12:13 pm, Leif <l...@leifrilbe.com> wrote:


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
egg  
View profile  
 More options Jan 18 2011, 1:48 am
From: egg <t.eg...@gmail.com>
Date: Mon, 17 Jan 2011 22:48:44 -0800 (PST)
Local: Tues, Jan 18 2011 1:48 am
Subject: Re: custom attributes in library projects
I also just encountered a same problem.

On  2010年12月28日, 午後4:08, schwiz <sch...@gmail.com> wrote:


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Premier  
View profile  
 More options Feb 8 2011, 8:48 am
From: Premier <a.grum...@gmail.com>
Date: Tue, 8 Feb 2011 05:48:44 -0800 (PST)
Local: Tues, Feb 8 2011 8:48 am
Subject: Re: custom attributes in library projects
Same problem.

On 18 Gen, 07:48, egg <t.eg...@gmail.com> wrote:


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Adam Tybor  
View profile  
 More options Feb 8 2011, 9:01 am
From: Adam Tybor <adam.ty...@gmail.com>
Date: Tue, 8 Feb 2011 06:01:27 -0800 (PST)
Local: Tues, Feb 8 2011 9:01 am
Subject: Re: custom attributes in library projects

Its not great but what I have been doing is using includes and redefining
the include in the application project.  You can still define the attribute
in the library project, you can use simple framelayouts or whatever to
define a fake placeholder layout in the library project, then in the
application project define the real view.  When compiling the real view in
the application project it will override the library project.  This allows
the code to compile with the R.syles stuff in the lirbary, yet still have
the views work too.

Best of luck, its kludgy but workable.
Adam

<< Library >>
res/values/attrs.xml:
<resources>
        <declare-styleable name="MyWidget">
                <attr name="customValue" format="integer"/>
        </declare-styleable>
</resources>

res/layout/myWidget.xml
<TextView
    android:id="@+id/my_widget"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:text="Replace Me"/>

res/layout/main.xml:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/
android"
    android:orientation="vertical"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    >
    <include layout="@layout/myWidget.xml" android:id="@+id/my_widget" />
</LinearLayout>

<< App Project>>
res/layout/myWidget.xml
<com.mycompany.test.lib.MyWidget xmlns:android="
http://schemas.android.com/apk/res/android"
        xmlns:my="http://schemas.android.com/apk/res/
    android:id="@+id/my_widget"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    my:customValue="324"/>


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Romain  
View profile  
 More options Feb 24 2011, 6:41 am
From: Romain <choicesm...@gmail.com>
Date: Thu, 24 Feb 2011 03:41:39 -0800 (PST)
Local: Thurs, Feb 24 2011 6:41 am
Subject: Re: [android-developers] custom attributes in library projects

Hi,

Any chance this has been fixed - or a workaround is available?

Library projects seem to be the best approach to release multiple versions
of an app (ex: free/paid),
and I was really hoping there is a better solution than to duplicate all of
my custom layouts in both apps.

Many thanks,

Romain


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
C. Plantier  
View profile  
 More options Mar 9 2011, 5:48 am
From: "C. Plantier" <clemplant...@gmail.com>
Date: Wed, 9 Mar 2011 02:48:28 -0800 (PST)
Local: Wed, Mar 9 2011 5:48 am
Subject: Re: custom attributes in library projects
This has been fixed (tested with latest SDK tools 10, platform API
11).

On Feb 24, 12:41 pm, Romain <choicesm...@gmail.com> wrote:


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
joebowbeer  
View profile  
 More options Mar 16 2011, 1:26 am
From: joebowbeer <joe.bowb...@gmail.com>
Date: Tue, 15 Mar 2011 22:26:11 -0700 (PDT)
Local: Wed, Mar 16 2011 1:26 am
Subject: Re: custom attributes in library projects
What has been fixed and tested?

Issue 9656?

http://code.google.com/p/android/issues/detail?id=9656

Is it now possible to declare a custom attribute in a library project
and reuse it in multiple apps?

If so, what xmlns does one use when declaring this attribute?  The
namespace of the library, or what?

Thanks in advance.

Joe

On Mar 9, 3:48 am, "C. Plantier" <clemplant...@gmail.com> wrote:


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Clément Plantier  
View profile  
 More options Mar 16 2011, 4:53 am
From: Clément Plantier <clemplant...@gmail.com>
Date: Wed, 16 Mar 2011 01:53:22 -0700 (PDT)
Local: Wed, Mar 16 2011 4:53 am
Subject: Re: custom attributes in library projects
Issue 9656 says it's not possible to have custom attributes declared &
used in library projects. This is fixed on SDK 11.

About using an attribute that is declared in a library projet in
multiple applications, I can't answer. Have you tried? What happens
when you do it?

On Mar 16, 6:26 am, joebowbeer <joe.bowb...@gmail.com> wrote:


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Mark Murphy  
View profile  
 More options Mar 16 2011, 7:24 am
From: Mark Murphy <mmur...@commonsware.com>
Date: Wed, 16 Mar 2011 07:24:58 -0400
Local: Wed, Mar 16 2011 7:24 am
Subject: Re: [android-developers] Re: custom attributes in library projects

On Wed, Mar 16, 2011 at 1:26 AM, joebowbeer <joe.bowb...@gmail.com> wrote:
> What has been fixed and tested?

> Issue 9656?

> http://code.google.com/p/android/issues/detail?id=9656

> Is it now possible to declare a custom attribute in a library project
> and reuse it in multiple apps?

This has worked for many months, at least since September. For example:

https://github.com/commonsguy/cwac-colormixer

> If so, what xmlns does one use when declaring this attribute?  The
> namespace of the library, or what?

The namespace of the hosting application:

xmlns:parcel="http://schemas.android.com/apk/res/com.commonsware.cwac.colormixer.demo"

(for an application in com.commonsware.cwac.colormixer.demo reusing a library)

--
Mark Murphy (a Commons Guy)
http://commonsware.com | http://github.com/commonsguy
http://commonsware.com/blog | http://twitter.com/commonsguy

_The Busy Coder's Guide to Android Development_ Version 3.5 Available!


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Emanuel Moecklin  
View profile  
 More options Mar 16 2011, 9:02 am
From: Emanuel Moecklin <1gravity...@gmail.com>
Date: Wed, 16 Mar 2011 06:02:51 -0700 (PDT)
Local: Wed, Mar 16 2011 9:02 am
Subject: Re: [android-developers] Re: custom attributes in library projects

You are accessing custom attributes in Java code but this thread is about
using custom attributes in xml layouts.
In your example that would be e.g. having
parcel:color="@android:color/black" in cwac_colormixer_activity.xml.
I'm not even sure why you need the namespace declaration in your layouts (
xmlns:parcel=
"http://schemas.android.com/apk/res/com.commonsware.cwac.colormixer.demo")
if you are not accessing the attributes in the xml.
If you would then you would get a compilation error because the package name
in your library project is com.commonsware.cwac.colormixer and not com.commonsware.cwac.colormixer.demo
--> the compiler would't find the custom attributes.

As far as I can see there's no fix in Android 11.

Emanuel Moecklin


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Mark Murphy  
View profile  
 More options Mar 16 2011, 9:08 am
From: Mark Murphy <mmur...@commonsware.com>
Date: Wed, 16 Mar 2011 09:08:56 -0400
Local: Wed, Mar 16 2011 9:08 am
Subject: Re: [android-developers] Re: custom attributes in library projects

On Wed, Mar 16, 2011 at 9:02 AM, Emanuel Moecklin <1gravity...@gmail.com> wrote:
> You are accessing custom attributes in Java code but this thread is about
> using custom attributes in xml layouts.
> In your example that would be e.g. having
> parcel:color="@android:color/black" in cwac_colormixer_activity.xml.
> I'm not even sure why you need the namespace declaration in your layouts
> (xmlns:parcel="http://schemas.android.com/apk/res/com.commonsware.cwac.colormixer.demo")
> if you are not accessing the attributes in the xml.
> If you would then you would get a compilation error because the package name
> in your library project is com.commonsware.cwac.colormixer and not
> com.commonsware.cwac.colormixer.demo --> the compiler would't find the
> custom attributes.
> As far as I can see there's no fix in Android 11.

Oops, sorry. I'll have to take a look at this.

BTW, AFAIK, the fix would be with the tools, not the SDK.

--
Mark Murphy (a Commons Guy)
http://commonsware.com | http://github.com/commonsguy
http://commonsware.com/blog | http://twitter.com/commonsguy

_The Busy Coder's Guide to Android Development_ Version 3.5 Available!


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
joebowbeer  
View profile  
 More options Mar 16 2011, 3:42 pm
From: joebowbeer <joe.bowb...@gmail.com>
Date: Wed, 16 Mar 2011 12:42:58 -0700 (PDT)
Local: Wed, Mar 16 2011 3:42 pm
Subject: Re: custom attributes in library projects
In my tests with the latest tools, the custom attribute's namespace
declaration in the library project needs to match the package
declaration of the including project.  Correct?

As far as I can tell, this is a known limitation and the suggested
workaround is to copy the affected resources (e.g., main.xml in the
example above) into each of the including projects.

On Mar 16, 1:53 am, Clément Plantier <clemplant...@gmail.com> wrote:


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Emanuel Moecklin  
View profile  
 More options Mar 16 2011, 9:38 pm
From: Emanuel Moecklin <1gravity...@gmail.com>
Date: Wed, 16 Mar 2011 18:38:10 -0700 (PDT)
Local: Wed, Mar 16 2011 9:38 pm
Subject: Re: custom attributes in library projects

On Wednesday, March 16, 2011 3:42:58 PM UTC-4, joebowbeer wrote:

> In my tests with the latest tools, the custom attribute's namespace
> declaration in the library project needs to match the package
> declaration of the including project.  Correct?

It has to match the package declaration in AndroidManifest.xml otherwise the
layout will not compile.
If the package is the same as the including project then you are right but
library projects make sense if you have at least two including projects
(free and paid app e.g.) which will obviously have different package
declarations if you want to publish them on Android market. With two
including projects with different package declarations it's obviously not
possible to match both.

> As far as I can tell, this is a known limitation and the suggested
> workaround is to copy the affected resources (e.g., main.xml in the
> example above) into each of the including projects.

See Xavier's post from July 2010. Please read the whole thread before
repeating what others have written.

Emanuel Moecklin


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
joebowbeer  
View profile  
 More options Mar 16 2011, 11:46 pm
From: joebowbeer <joe.bowb...@gmail.com>
Date: Wed, 16 Mar 2011 20:46:13 -0700 (PDT)
Local: Wed, Mar 16 2011 11:46 pm
Subject: Re: custom attributes in library projects
Thanks for confirming my findings, Emanuel!

Sorry for not clarifying in my response that I had read the earlier
thread.

I also read that "this" was fixed recently, which is why I'm asking
for an update.

Joe

On Mar 16, 6:38 pm, Emanuel Moecklin <1gravity...@gmail.com> wrote:


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Emanuel Moecklin  
View profile  
 More options Mar 17 2011, 9:09 am
From: Emanuel Moecklin <1gravity...@gmail.com>
Date: Thu, 17 Mar 2011 06:09:55 -0700 (PDT)
Local: Thurs, Mar 17 2011 9:09 am
Subject: Re: custom attributes in library projects
Hi Joe

I don't think it has been fixed. Can't find anything in the SDK Tools
release notes and it still doesn't compile if the namespace doesn't
match the package declaration.

Sorry
Emanuel


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Izhovkin  
View profile  
 More options Oct 19 2011, 3:51 am
From: Izhovkin <izhov...@gmail.com>
Date: Wed, 19 Oct 2011 00:51:50 -0700 (PDT)
Local: Wed, Oct 19 2011 3:51 am
Subject: Re: [android-developers] custom attributes in library projects

Was this issue fixed in sdk tools r14?


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Xavier Ducrohet  
View profile  
 More options Oct 19 2011, 4:26 pm
From: Xavier Ducrohet <x...@android.com>
Date: Wed, 19 Oct 2011 13:26:38 -0700
Local: Wed, Oct 19 2011 4:26 pm
Subject: Re: [android-developers] custom attributes in library projects
not yet.

On Wed, Oct 19, 2011 at 12:51 AM, Izhovkin <izhov...@gmail.com> wrote:
> Was this issue fixed in sdk tools r14?

> --
> You received this message because you are subscribed to the Google
> Groups "Android Developers" group.
> To post to this group, send email to android-developers@googlegroups.com
> To unsubscribe from this group, send email to
> android-developers+unsubscribe@googlegroups.com
> For more options, visit this group at
> http://groups.google.com/group/android-developers?hl=en

--
Xavier Ducrohet
Android SDK Tech Lead
Google Inc.
http://developer.android.com | http://tools.android.com

Please do not send me questions directly. Thanks!


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Jay Kline  
View profile  
 More options Mar 1 2012, 3:22 pm
From: Jay Kline <j...@slushpupie.com>
Date: Thu, 1 Mar 2012 12:22:40 -0800 (PST)
Local: Thurs, Mar 1 2012 3:22 pm
Subject: Re: custom attributes in library projects

Im using a slightly better kludge.  Instead of having to include the xml
files, I declare the namespace as a string resource.  So in your layout
just do   xmlns:my="@string/package_ns" then just have the project that
uses it define the namespace.  Seems to work ok.


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Messages 1 - 25 of 28   Newer >
« Back to Discussions « Newer topic     Older topic »