Search code examples
xamarin.androidassets

access assets from monodroid class library


Is it possible to access files (with build action "AndroidAsset") from a monodroid class library in a monodroid application that references the class library ?

I have created an "Assets" folder in the class lib and added a text file with build action "AndroidAsset", but from the app I could not access it via Assets.Open("file.txt");

I was hoping that the Assets from the class lib and the main application could somehow be "merged"...


Solution

  • No - you a can't access the assets from a class lib - only from the main exe project.

    This is similar to the situation with Java Android projects.


    One route around this might be to use embedded resources instead - see the answer to this question I asked on xamarin's forums - http://forums.xamarin.com/discussion/186/is-there-a-cross-platform-way-to-include-string-resources-from-class-library-projects - note that I haven't tried this yet