Resource files in library projects?

StuartLodgeStuartLodge Stuart LodgeUSBeta ✭✭✭

I know this has been discussed before - http://mono-for-android.1047100.n5.nabble.com/Resources-in-Class-Library-project-td5658638.html

And it seems like this might be available now - e.g. I've seen this code change https://github.com/atsushieno/MonoDroid.Dialog/commit/2c7c5daf83e33b3a19d60400437cc5cd4655cee7

Is this functionality available now? If so, which versions of MonoDroid are needed?

:)

Stuart

Posts

  • JonathanPryorJonathanPryor Jonathan Pryor USModerator, Xamarin Team Xamurai

    Mono for Android 4.4 added support for Android Resources within Library projects:

    Library Projects can now contain Android Resources.

    However, just because it's possible doesn't mean it's easy; the current Library project templates don't have any of the "infrastructure" required to actually build them. We'll need to rectify this in a future release.

    In the meantime, I would suggest creating a new Application project, then hand-edit the .csproj and remove the following element:

    <AndroidApplication>True</AndroidApplication>
    
  • StuartLodgeStuartLodge Stuart Lodge USBeta ✭✭✭

    I've been trying to get this working - initially trying to get ActionBarSherlock inside Xamarin/MonoDroidSamples to use resources from a lib

    So far... some luck but not too much :(

    I think the point I'm failing at is the regeneration of the Resources.designer.cs file in the resource class library.

    Is there a working reference sample somewhere I can take a look at - just to use WinMerge to work out what is different between my hack-application-library and one that works.

    Thanks - loving the idea of this

    Stuart

  • JonathanPryorJonathanPryor Jonathan Pryor USModerator, Xamarin Team Xamurai

    Check out the ManagedAndroidResourceTest sample.

  • StuartLodgeStuartLodge Stuart Lodge USBeta ✭✭✭

    I can't get this sample project to build at the moment - just says it can't find the string resource identifier

    Using VS2012 and MonoDroid 4.4.54

  • atsushienoatsushieno Atsushi Enomoto JPXamarin Team Xamurai

    Hi Stuart,

    I'm not sure what you are trying to do - IF you are going to mix resources in library project and ActionBarSherlock jar, it won't work - ABS is an Android library project (not in the context of MfA's mere 'library' project) and that requires resources bundled as a LibraryProjectZip. "Android resources in library project" will never work as "mere .jar file AND resources in some library". That's not how Android aapt works. If that's the case, just stick to old JarBinding approach i.e. LibraryProjectZip.

    If you are trying to add resources to any existing library projects that was created before 4.2.7, it won't work. Only those library projects that are created after 4.2.8 support AndroidResources. For details, see http://lists.ximian.com/pipermail/monodroid/2012-December/013135.html

    (And yes, it still seems to be an issue that if you use VS, as you wrote above, it won't add as jonp commented; we're sorry for inconvenience.)

    If neither of those case, please come up with the actual steps you tried, so that we can help and diagnose what's causing the problem.

  • StuartLodgeStuartLodge Stuart Lodge USBeta ✭✭✭

    Thanks @eno

    I'm not sure what I'm trying to do - I was mainly just trying to get a first sample working and then latter proper work can follow.

    However - I've not managed to get anything working :( I work mainly in Visual Studio - so I guess that is the reason.

    I'll park this now - come back to it when the VS support works - or when I can build WP and WinRT in MonoDevelop :)

    Thanks to both of you for your time, and for the new feature - I think the idea behind the feature is really good and really important - I love the idea of shipping the resources for Mvx, CrossUI, MonoDroid.Dialog, etc all with the resources built into the assemblies.

    Top work :)

    Stuart

Sign In or Register to comment.