Resources from a Library Project

classic Classic list List threaded Threaded
6 messages Options
Reply | Threaded
Open this post in threaded view
|

Resources from a Library Project

riteshsahu
I want to have a Library project where I'll have resources that are shared across various other projects, Themes, Styles, Common images etc.
When I create a new Android Library Project, the template does not create the Resources folder hierarchy. I tried creating the folders and files inside them manually but then the Resource.Designer.cs does not get generated.
I managed to get it to generate by adding <AndroidApplication>true</AndroidApplication> in the csproj file but when I try to use any of the resources in a project, the app crashes. Some of the errors in logcat:

W/ResourceType(  627): Bad XML block: header size 18254 or total size 169478669
is larger than data size 3966
I/MonoDroid(  627): UNHANDLED EXCEPTION: Android.Content.Res.Resources+NotFoundE
xception: Exception of type 'Android.Content.Res.Resources+NotFoundException' was thrown.
I/MonoDroid(  627): android.content.res.Resources$NotFoundException: File res/dr
awable/icon.png from xml type layout resource ID #0x7f020000
I/MonoDroid(  627):     at android.content.res.Resources.loadXmlResourceParser(R
esources.java:1912)
I/MonoDroid(  627):     at android.content.res.Resources.loadXmlResourceParser(R
esources.java:1867)

I'm guessing there is no proper support of these things with Mono for Android yet, is it something in the works? Whats the suggested way of sharing Resources?


Reply | Threaded
Open this post in threaded view
|

Re: Resources from a Library Project

riteshsahu
I've looked a bit more into this and by the looks of it the R.java created only contains the ID from the Application and doesn't contain anything from the Libraries. The values assigned to these constants are overlapped between different projects (// aapt resource value: 0x7f020000).

Using these results in the app trying to load the named resource from the application rather than the library.

Again, what is the recommended way of sharing resources across projects?
Reply | Threaded
Open this post in threaded view
|

Re: Resources from a Library Project

Jonathan Pobst
There is currently no support for sharing resources across projects.

You will need to copy (or link) the resources into each project.

Hopefully there will eventually be a better solution for this.

Jonathan


On 8/2/2011 7:09 PM, riteshsahu wrote:

> I've looked a bit more into this and by the looks of it the R.java created
> only contains the ID from the Application and doesn't contain anything from
> the Libraries. The values assigned to these constants are overlapped between
> different projects (// aapt resource value: 0x7f020000).
>
> Using these results in the app trying to load the named resource from the
> application rather than the library.
>
> Again, what is the recommended way of sharing resources across projects?
>
> --
> View this message in context: http://mono-for-android.1047100.n5.nabble.com/Resources-from-a-Library-Project-tp4657828p4660735.html
> Sent from the Mono for Android mailing list archive at Nabble.com.
> _______________________________________________
> Monodroid mailing list
> [hidden email]
>
> UNSUBSCRIBE INFORMATION:
> http://lists.ximian.com/mailman/listinfo/monodroid
>
>

_______________________________________________
Monodroid mailing list
[hidden email]

UNSUBSCRIBE INFORMATION:
http://lists.ximian.com/mailman/listinfo/monodroid
Reply | Threaded
Open this post in threaded view
|

Re: Resources from a Library Project

Rebeca Perez
Hey honey you were really good last night in bed and then twice this morning. That's was sooo hot! I can't wait for your big black cock again :-)

On Aug 2, 2011, at 11:36 PM, Jonathan Pobst <[hidden email]> wrote:

> There is currently no support for sharing resources across projects.
>
> You will need to copy (or link) the resources into each project.
>
> Hopefully there will eventually be a better solution for this.
>
> Jonathan
>
>
> On 8/2/2011 7:09 PM, riteshsahu wrote:
>> I've looked a bit more into this and by the looks of it the R.java created
>> only contains the ID from the Application and doesn't contain anything from
>> the Libraries. The values assigned to these constants are overlapped between
>> different projects (// aapt resource value: 0x7f020000).
>>
>> Using these results in the app trying to load the named resource from the
>> application rather than the library.
>>
>> Again, what is the recommended way of sharing resources across projects?
>>
>> --
>> View this message in context: http://mono-for-android.1047100.n5.nabble.com/Resources-from-a-Library-Project-tp4657828p4660735.html
>> Sent from the Mono for Android mailing list archive at Nabble.com.
>> _______________________________________________
>> Monodroid mailing list
>> [hidden email]
>>
>> UNSUBSCRIBE INFORMATION:
>> http://lists.ximian.com/mailman/listinfo/monodroid
>>
>>
>
> _______________________________________________
> Monodroid mailing list
> [hidden email]
>
> UNSUBSCRIBE INFORMATION:
> http://lists.ximian.com/mailman/listinfo/monodroid
_______________________________________________
Monodroid mailing list
[hidden email]

UNSUBSCRIBE INFORMATION:
http://lists.ximian.com/mailman/listinfo/monodroid
Reply | Threaded
Open this post in threaded view
|

Re: Resources from a Library Project

riteshsahu
In reply to this post by Jonathan Pobst
Thanks Jonathan.
I've seen that even if I don't try to use resources we can't put
anything UI related in library projects.
For example:
I have a Library project (lets call it LibProj)
I have an Activity (Activity1) in LibProj which loads a layout using

SetContentView(Resource.Layout.Main);

The Layout Main.axml is within that library project.

Now I have a Mono Android Application Project (AppProj) which references
LibProj and then creates an intent to start a Activity1:

Intent intent = new Intent(this, typeof(LibProj.Activity1));
StartActivity(intent);


What happens to this call completely depends on what const Id was
generated for Resource.Layout.Main and if the AppProj has something in
the Resource file with a similar Id. I've seen it loading a completely
different layout (a layout defined in AppProj).

With this behavior, it's almost impossible to use Library projects
except for business logic (I guess that's why the Resource folder
hierarchy is not generated in Library projects). Anything UI related
(Activity, View, Layout etc) have to be put in the Application Project.

I certainly hope this is something that gets fixed soonish otherwise
it'll make it very difficult for us to develop applications of any
decent complexity using Mono for Android if we have to put all UI stuff
in one project.

- Ritesh

-----Original Message-----
From: Jonathan Pobst [mailto:[hidden email]]
Sent: Wednesday, 3 August 2011 1:37 PM
To: Discussions related to Mono for Android
Cc: Ritesh Sahu
Subject: Re: [mono-android] Resources from a Library Project

There is currently no support for sharing resources across projects.

You will need to copy (or link) the resources into each project.

Hopefully there will eventually be a better solution for this.

Jonathan


On 8/2/2011 7:09 PM, riteshsahu wrote:
> I've looked a bit more into this and by the looks of it the R.java
created
> only contains the ID from the Application and doesn't contain anything
from
> the Libraries. The values assigned to these constants are overlapped
between
> different projects (// aapt resource value: 0x7f020000).
>
> Using these results in the app trying to load the named resource from
the
> application rather than the library.
>
> Again, what is the recommended way of sharing resources across
projects?
>
> --
> View this message in context:
http://mono-for-android.1047100.n5.nabble.com/Resources-from-a-Library-P
roject-tp4657828p4660735.html
> Sent from the Mono for Android mailing list archive at Nabble.com.
> _______________________________________________
> Monodroid mailing list
> [hidden email]
>
> UNSUBSCRIBE INFORMATION:
> http://lists.ximian.com/mailman/listinfo/monodroid
>
>



Click
https://www.mailcontrol.com/sr/wQw0zmjPoHdJTZGyOCrrhg==
eHGjiy6gkGpcMqwkE3vFhNIomf0VqRQWLTieLvRJKIvyA==  to report this email as
spam.
--------------------------------------------------------

This e-mail is for the use of the intended recipient(s) only. If you have received this e-mail in error, please notify the sender immediately and then delete it. If you are not the intended recipient, you must not use, disclose or distribute this e-mail without the author's prior permission. We have taken precautions to minimize the risk of transmitting software viruses, but we advise you to carry out your own virus checks on any attachment to this message. We cannot accept liability for any loss or damage caused by software viruses. Any views and/or opinions expressed in this e-mail are of the author only and do not represent the views of Epicor Software Corporation or any other company within its group.


This message has been scanned for malware by Websense. www.websense.com
_______________________________________________
Monodroid mailing list
[hidden email]

UNSUBSCRIBE INFORMATION:
http://lists.ximian.com/mailman/listinfo/monodroid
Reply | Threaded
Open this post in threaded view
|

Re: Resources from a Library Project

Anthony.Coqui
In reply to this post by Jonathan Pobst
I too would like this ability in the future :)

-----Original Message-----
From: [hidden email]
[mailto:[hidden email]] On Behalf Of Ritesh Sahu
Sent: Wednesday, August 03, 2011 12:30 AM
To: Jonathan Pobst; Discussions related to Mono for Android
Subject: Re: [mono-android] Resources from a Library Project

Thanks Jonathan.
I've seen that even if I don't try to use resources we can't put anything UI
related in library projects.
For example:
I have a Library project (lets call it LibProj) I have an Activity
(Activity1) in LibProj which loads a layout using

SetContentView(Resource.Layout.Main);

The Layout Main.axml is within that library project.

Now I have a Mono Android Application Project (AppProj) which references
LibProj and then creates an intent to start a Activity1:

Intent intent = new Intent(this, typeof(LibProj.Activity1));
StartActivity(intent);


What happens to this call completely depends on what const Id was generated
for Resource.Layout.Main and if the AppProj has something in the Resource
file with a similar Id. I've seen it loading a completely different layout
(a layout defined in AppProj).


With this behavior, it's almost impossible to use Library projects except
for business logic (I guess that's why the Resource folder hierarchy is not
generated in Library projects). Anything UI related (Activity, View, Layout
etc) have to be put in the Application Project.

I certainly hope this is something that gets fixed soonish otherwise it'll
make it very difficult for us to develop applications of any decent
complexity using Mono for Android if we have to put all UI stuff in one
project.

- Ritesh

-----Original Message-----
From: Jonathan Pobst [mailto:[hidden email]]
Sent: Wednesday, 3 August 2011 1:37 PM
To: Discussions related to Mono for Android
Cc: Ritesh Sahu
Subject: Re: [mono-android] Resources from a Library Project

There is currently no support for sharing resources across projects.

You will need to copy (or link) the resources into each project.

Hopefully there will eventually be a better solution for this.

Jonathan


On 8/2/2011 7:09 PM, riteshsahu wrote:
> I've looked a bit more into this and by the looks of it the R.java
created
> only contains the ID from the Application and doesn't contain anything
from
> the Libraries. The values assigned to these constants are overlapped
between
> different projects (// aapt resource value: 0x7f020000).
>
> Using these results in the app trying to load the named resource from
the
> application rather than the library.
>
> Again, what is the recommended way of sharing resources across
projects?
>
> --
> View this message in context:
http://mono-for-android.1047100.n5.nabble.com/Resources-from-a-Library-P
roject-tp4657828p4660735.html
> Sent from the Mono for Android mailing list archive at Nabble.com.
> _______________________________________________
> Monodroid mailing list
> [hidden email]
>
> UNSUBSCRIBE INFORMATION:
> http://lists.ximian.com/mailman/listinfo/monodroid
>
>



Click
https://www.mailcontrol.com/sr/wQw0zmjPoHdJTZGyOCrrhg==
eHGjiy6gkGpcMqwkE3vFhNIomf0VqRQWLTieLvRJKIvyA==  to report this email as
spam.
--------------------------------------------------------

This e-mail is for the use of the intended recipient(s) only. If you have
received this e-mail in error, please notify the sender immediately and then
delete it. If you are not the intended recipient, you must not use, disclose
or distribute this e-mail without the author's prior permission. We have
taken precautions to minimize the risk of transmitting software viruses, but
we advise you to carry out your own virus checks on any attachment to this
message. We cannot accept liability for any loss or damage caused by
software viruses. Any views and/or opinions expressed in this e-mail are of
the author only and do not represent the views of Epicor Software
Corporation or any other company within its group.


This message has been scanned for malware by Websense. www.websense.com
_______________________________________________
Monodroid mailing list
[hidden email]

UNSUBSCRIBE INFORMATION:
http://lists.ximian.com/mailman/listinfo/monodroid

_______________________________________________
Monodroid mailing list
[hidden email]

UNSUBSCRIBE INFORMATION:
http://lists.ximian.com/mailman/listinfo/monodroid