[FIXED] Full project folder path necessary to access Assets in Xamarin Android



In VS for Mac it actually works as intended. The described behaviour only occurs in Rider 2022.2.2 for me.

Original Question

In my Xamarin Android project I have a folder "Assets" including an asset file "certificate.crt". The build action of the file is set to AndroidAsset. To be able to access the asset with the asset manager I have to specify the full file path.

var assetManager = Android.App.Application.Context.Assets;
using (var certStream = assetManager.Open("Users/myuser/Documents/Projects/MyProject/MyProject.Android/Assets/certificate.crt"))
    // use the certStream

I found the file path by renaming the .apk to .zip and extracting the files then. So the .apk included an "Assets" folder and in there were all the folders specified above. But what I obviously want is to just pass the filename to the assets manager.


How do I achieve that?


So it seems to be a bug in Rider for Mac. VS for Mac works as expected.

Answered By – frichter

Answer Checked By – David Marino (Easybugfix Volunteer)

Leave a Reply

(*) Required, Your email will not be published