Closed hansmbakker closed 7 months ago
Thanks! 😄
I would hope the resizetizer only touches compatible image formats. I agree this is not the best place and I originally put them in the Resources/Raw
folder but was unable to get the identifier in Android. See RiveRenderer.cs#L43 tried with "raw" instead of "drawable" but still returned 0. iOS was fine.
If you have time, maybe you can look at it?
It looks like putting them in the Images folder is the way that will work (unless you want to create your own MSBuild task which I doubt :) )
So I looked into it - the explainer file in the Resources/Raw
folder says that MauiAsset
files need to be used with FileSystem.OpenAppPackageFileAsync(string filename)
.
This function calls Application.Context.Assets.Open(filename);
which points out that it does not use Android Raw Resources but Assets.
The Android documentation `says:
However, if you need access to the original filenames and file hierarchy, consider saving resources in the
assets/
directory instead ofres/raw/
. Files inassets/
aren't given a resource ID, so you can only read them using `AssetManager .
So it looks like putting a file in the Resources/Raw
MAUI folder (marking them as MauiAsset
) does not result in those files getting a Resource Identifier.
@matmork for the sake of completeness:
The correct location for Android
raw
resources isPlatforms/Android/Resources/raw
. They must also have a build action ofAndroidresource
(this should be the default forPlatforms/Android/Resources/**/*
.
(See https://github.com/dotnet/maui/issues/10580#issuecomment-1279294398)
I see she building an app where users want to include a Rive file on all platforms, having them in one location (like the Resources/Images folder) is more practical
@hansmbakker Thanks for your research! Learnt something new.
Hi, Super cool to see the progress you're making!
I had a question about the guidance to put the riv files in the
Resources/Images
- if files are put there then they are automatically marked with theMauiImage
build action which might call resizetizer on them and maybe other side effects.What were your considerations of this vs putting those files in the
Resources/Raw
folder?