dotnet / android

.NET for Android provides open-source bindings of the Android SDK for use with .NET managed languages such as C#
MIT License
1.93k stars 532 forks source link

Satellite assemblies for other locales than the default are not deployed when EmbedAssembliesIntoApk = true #9532

Open Cheesebaron opened 1 day ago

Cheesebaron commented 1 day ago

Android framework version

net9.0-android

Affected platform version

.NET 9.0.100

Description

When I debug an application where csproj contains <EmbedAssembliesIntoApk>true</EmbedAssembliesIntoApk> for the configuration I am running it appears like satellite assemblies for other languages than the neutral one are not deployed with the App.

This means that at runtime when switching languages using something like:

CultureInfo.DefaultThreadCurrentCulture = newCultureInfo;
CultureInfo.DefaultThreadCurrentUICulture = newCultureInfo;

Then grabbing strings from the Resx files we use, always yield the strings from the neutral language.

Looking at the output from the App at runtime you will see:

11-20 10:37:05.346 W/monodroid-assembly( 7723): open_from_bundles: failed to load bundled assembly de-DE/TrackMan.Api.Measures.resources.dll
11-20 10:37:05.346 W/monodroid-assembly( 7723): open_from_bundles: the assembly might have been uploaded to the device with FastDev instead
11-20 10:37:05.346 W/monodroid-assembly( 7723): open_from_bundles: failed to load bundled assembly de-DE/TrackMan.Api.Measures.resources.dll
11-20 10:37:05.346 W/monodroid-assembly( 7723): open_from_bundles: the assembly might have been uploaded to the device with FastDev instead
11-20 10:37:05.347 W/monodroid-assembly( 7723): open_from_bundles: failed to load bundled assembly de/TrackMan.Api.Measures.resources.dll
11-20 10:37:05.347 W/monodroid-assembly( 7723): open_from_bundles: the assembly might have been uploaded to the device with FastDev instead
11-20 10:37:05.347 W/monodroid-assembly( 7723): open_from_bundles: failed to load bundled assembly de/TrackMan.Api.Measures.resources.dll
11-20 10:37:05.347 W/monodroid-assembly( 7723): open_from_bundles: the assembly might have been uploaded to the device with FastDev instead

Steps to Reproduce

Repro repository can be found here: https://github.com/Cheesebaron/EmbedAssembliesIntoApkRepro

Did you find any workaround?

Setting EmbedAssembliesIntoApk to false seems to alleviate this issue.

Relevant log output

dellis1972 commented 1 day ago

So I managed to repo the issue with the sample provided.

Oddly lib/arm64-v8a/lib-de-DE-Shared.resources.dll.so and lib/x86_64/lib-de-DE-Shared.resources.dll.so are both present in the apk! So this means something else is going on.

dellis1972 commented 1 day ago

Relevant adb log output

11-20 11:09:11.240  7854  7854 W monodroid-assembly: open_from_bundles: failed to load bundled assembly de-DE/Shared.resources.dll
11-20 11:09:11.240  7854  7854 W monodroid-assembly: open_from_bundles: the assembly might have been uploaded to the device with FastDev instead
11-20 11:09:11.240  7854  7854 W monodroid-assembly: open_from_bundles: failed to load bundled assembly de-DE/Shared.resources.dll
11-20 11:09:11.240  7854  7854 W monodroid-assembly: open_from_bundles: the assembly might have been uploaded to the device with FastDev instead
11-20 11:09:11.292  7854  7854 W monodroid-assembly: open_from_bundles: failed to load bundled assembly de/Shared.resources.dll
11-20 11:09:11.292  7854  7854 W monodroid-assembly: open_from_bundles: the assembly might have been uploaded to the device with FastDev instead
11-20 11:09:11.292  7854  7854 W monodroid-assembly: open_from_bundles: failed to load bundled assembly de/Shared.resources.dll
11-20 11:09:11.292  7854  7854 W monodroid-assembly: open_from_bundles: the assembly might have been uploaded to the device with FastDev instead
--------- beginning of kernel