Xamarin-android: Localized RESX resources are missing in debug builds using 11.2.0.0

Created on 24 Jan 2021  路  12Comments  路  Source: xamarin/xamarin-android

Steps to Reproduce

  1. Clone the git project at https://github.com/xamarin/xamarin-forms-samples/tree/master/UsingResxLocalization
  2. Install _Visual Studio for Mac version 8.9 Preview 3_
  3. Set the device locale to a Spanish locale (e.g., Espanol Estados Unidos).
  4. Build and run the Android project in debug mode, connecting to the default Android 9 Pixel emulator created by Visual Studio for Mac's Android Device Manager.
  5. Click on the list cells for each of the two demo pages ("Localization XAML Demo" and "Localization Code Demo".

Expected Behavior

  1. Observe that the text and flag shown on both localized Demo pages are locale-appropriate.
  2. Connect to device via "adb shell" command.
  3. Find satellite assemblies in one of the places that logcat shows the device probing (search logcat for "Assembly Loader probing location"). Use "run-as" if needed to get access to app-private storage.

Actual Behavior

  1. Observe that the text shown on both localized Demo pages is in the default locale (English - _unexpected_) but the flags are locale-appropriate (Spanish - _expected_).
  2. Connect to device via "adb shell" command.
  3. Fail to find satellite assemblies in one of the places that logcat shows the device probing (search logcat for "Assembly Loader probing location"). Use "run-as" if needed to get access to app-private storage.

Version Information

=== Visual Studio Enterprise 2019 for Mac (Preview) ===

Version 8.9 Preview (8.9 build 1451)
Installation UUID: eef48a0d-ff3c-404e-ade8-9c190fb913b3
GTK+ 2.24.23 (Raleigh theme)
Xamarin.Mac 6.18.0.23 (d16-6 / 088c73638)

Package version: 612000113

=== Mono Framework MDK ===

Runtime:
Mono 6.12.0.113 (2020-02/4fdfb5b1fd5) (64-bit)
Package version: 612000113

=== Roslyn (Language Service) ===

3.9.0-3.20619.14+df59a33fd9beff9790e01a2a1ab21e4a1e6921b3

=== NuGet ===

Version: 5.8.0.6860

=== .NET Core SDK ===

SDK: /usr/local/share/dotnet/sdk/5.0.102/Sdks
SDK Versions:
5.0.102
3.1.405
MSBuild SDKs: /Applications/Visual Studio.app/Contents/Resources/lib/monodevelop/bin/MSBuild/Current/bin/Sdks

=== .NET Core Runtime ===

Runtime: /usr/local/share/dotnet/dotnet
Runtime Versions:
5.0.2
3.1.11

=== .NET Core 3.1 SDK ===

SDK: 3.1.405

=== Xamarin.Profiler ===

Version: 1.6.15.68
Location: /Applications/Xamarin Profiler.app/Contents/MacOS/Xamarin Profiler

=== Updater ===

Version: 11

=== Apple Developer Tools ===

Xcode 12.3 (17715)
Build 12C33

=== Xamarin.Mac ===

Version: 7.3.0.27 (Visual Studio Enterprise)
Hash: f4c9327fa
Branch: main
Build date: 2020-11-19 10:57:31-0500

=== Xamarin.Android ===

Version: 11.2.0.0 (Visual Studio Enterprise)
Commit: xamarin-android/d16-9/f908d16
Android SDK: /Users/georgekarabin/Library/Android/sdk
Supported Android versions:
4.4 (API level 19)

SDK Tools Version: 26.1.1
SDK Platform Tools Version: 30.0.4
SDK Build Tools Version: 30.0.2

Build Information:
Mono: 5e9cb6d
Java.Interop: xamarin/java.interop/d16-9@1d382be
ProGuard: Guardsquare/proguard/v7.0.1@912d149
SQLite: xamarin/sqlite/3.32.2@cfe06e0
Xamarin.Android Tools: xamarin/xamarin-android-tools/main@ad80a42

=== Microsoft OpenJDK for Mobile ===

Java SDK: /Users/georgekarabin/Library/Developer/Xamarin/jdk/microsoft_dist_openjdk_1.8.0.25
1.8.0-25
Android Designer EPL code available here:
https://github.com/xamarin/AndroidDesigner.EPL

=== Android SDK Manager ===

Version: 16.9.0.21
Hash: 57e40ba
Branch: remotes/origin/main
Build date: 2021-01-08 01:57:14 UTC

=== Android Device Manager ===

Version: 16.9.0.14
Hash: 0fdccda
Branch: remotes/origin/main
Build date: 2021-01-08 01:57:36 UTC

=== Xamarin.iOS ===

Version: 14.9.0.27 (Visual Studio Enterprise)
Hash: f4c9327fa
Branch: main
Build date: 2020-11-19 10:57:31-0500

=== Xamarin Designer ===

Version: 16.9.0.266
Hash: c4842c761
Branch: remotes/origin/c4842c761b9b6a95407f72278ca7fb42f8f7fdf0
Build date: 2021-01-07 06:17:08 UTC

=== Build Information ===

Release ID: 809001451
Git revision: cfd15313a6388ef8dada0182e22a058131c46f9d
Build date: 2021-01-15 08:42:21-05
Build branch: release-8.9
Xamarin extensions: cfd15313a6388ef8dada0182e22a058131c46f9d

=== Operating System ===

Mac OS X 10.16.0
Darwin 20.2.0 Darwin Kernel Version 20.2.0
Wed Dec 2 20:39:59 PST 2020
root:xnu-7195.60.75~1/RELEASE_X86_64 x86_64

Log File

logcat-missing-satellite-assemblies.txt

App Runtime

All 12 comments

I recall seeing the issue on an earlier version of the Visual Studio for Mac 8.9 Preview on an app that I maintain for my job. I don't recall if it was Preview 1 or 2. That app shows the same problem that I see for the localization sample app mentioned in this bug report using Preview 3.

Localization of both my app and the localization sample app works fine in Xamarin.iOS using all Visual Studio for Mac 8.9 Preview builds.

I can't duplicate this issue using the version of Xamarin.Android that comes with Visual Studio for Mac 8.8.6. I have not tried running preview builds of Visual Studio for Windows to see if the problem can be reproduced there or not.

Just to clarify, here is an image of the app running (getting its Android resource localized images correct for the current Android locale, but getting its satellite-assembly text resources incorrect):
Screenshot_1611457230

@dellis1972 I think this is something to do with Fast Deployment vNext...

When I deploy the app, I don't have the es/UsingResxLocalization.resources.dll assembly.

It seems I just have one in the root:

% adb shell run-as com.companyname.localizationdemo ls -la files/.__override__ | grep Using
-rw-rw-rw- 1 u0_a99 u0_a99   284672 2021-01-26 09:46 UsingResxLocalization.Android.dll
-rw-rw-rw- 1 u0_a99 u0_a99    56324 2021-01-26 09:46 UsingResxLocalization.Android.pdb
-rw-rw-rw- 1 u0_a99 u0_a99    14336 2021-01-26 09:46 UsingResxLocalization.dll
-rw-rw-rw- 1 u0_a99 u0_a99     9352 2021-01-26 09:46 UsingResxLocalization.pdb
-rw-rw-rw- 1 u0_a99 u0_a99     3072 2021-01-26 09:46 UsingResxLocalization.resources.dll

So I think it's losing the en and es subdirectories -- and only the English satellite assembly is deployed.

A Release build works fine here.

That all sounds correct, with one small caveat: the "en" directory isn't expected to be there, but "es" should be. There are no .resx files with a "en" culture in the app:

UsingResxLocalization % find . -name *.resx
./UsingResxLocalization/UsingResxLocalization/Resx/AppResources.id.resx
./UsingResxLocalization/UsingResxLocalization/Resx/AppResources.resx
./UsingResxLocalization/UsingResxLocalization/Resx/AppResources.zh-Hans.resx
./UsingResxLocalization/UsingResxLocalization/Resx/AppResources.es.resx
./UsingResxLocalization/UsingResxLocalization/Resx/AppResources.fr.resx
./UsingResxLocalization/UsingResxLocalization/Resx/AppResources.zh-Hant.resx
./UsingResxLocalization/UsingResxLocalization/Resx/AppResources.de.resx
./UsingResxLocalization/UsingResxLocalization/Resx/AppResources.de-CH.resx
./UsingResxLocalization/UsingResxLocalization/Resx/AppResources.pt.resx
./UsingResxLocalization/UsingResxLocalization/Resx/AppResources.pt-BR.resx
./UsingResxLocalization/UsingResxLocalization/Resx/AppResources.ja.resx
./UsingResxLocalization/UsingResxLocalization/Resx/AppResources.ms.resx

Instead, the neutral language (the language of AppResources.resx) is explicitly set to en-US, meaning that UsingResxLocalization.resources.dll is for that locale.

UsingResxLocalization/UsingResxLocalization/AssemblyInfo.cs
12:[assembly: NeutralResourcesLanguage("en-US")]

I believe that all of the other locales (_id, zh-Hans, es, fr, zh-Hant, de, de-CH, pt, pt-BR, ja, ms_) should also be present as satellite assemblies.

Thanks, I just sent a fix in a private repo, but I am able to see these after the fix:

% adb shell run-as com.companyname.localizationdemo find files/.__override__ | grep Using
files/.__override__/zh-Hans/UsingResxLocalization.resources.dll
files/.__override__/zh-Hant/UsingResxLocalization.resources.dll
files/.__override__/ms/UsingResxLocalization.resources.dll
files/.__override__/ja/UsingResxLocalization.resources.dll
files/.__override__/pt/UsingResxLocalization.resources.dll
files/.__override__/pt-BR/UsingResxLocalization.resources.dll
files/.__override__/de/UsingResxLocalization.resources.dll
files/.__override__/id/UsingResxLocalization.resources.dll
files/.__override__/fr/UsingResxLocalization.resources.dll
files/.__override__/es/UsingResxLocalization.resources.dll
files/.__override__/de-CH/UsingResxLocalization.resources.dll
files/.__override__/UsingResxLocalization.Android.dll
files/.__override__/UsingResxLocalization.dll
files/.__override__/UsingResxLocalization.Android.pdb
files/.__override__/UsingResxLocalization.pdb

Excellent! That looks like it should work if the app probes those spots.

For what it's worth, the developer community bug that I filed at https://developercommunity.visualstudio.com/t/Missing-horizontal-scroll-on-Build-Outpu/1280279?q=%5BFixed+In%3A+Visual+Studio+2019+version+16.9+Preview+5%5D&space=41 is marked as fixed in "preview 4". @jonathanpeppers - you noted that it should be going into VS 16.9 Preview 4, but it seems like it hasn't made it into VS for Mac 8.9 preview 4 (or 5) yet.

Maybe that's by design but it seems like there might be an oversight. Thanks for your help!

@gkarabin what version of Xamarin.Android do you have?

The fix looks like it would be in 11.2.0.18 or higher, do you want to try the newest builds:

These are what will probably be in 16.9 final, unless some other fixes go in.

From VS for Mac's "About Visual Studio" dialog:

Xamarin.Android
Version: 11.2.0.0 (Visual Studio Enterprise)
Commit: xamarin-android/d16-9/f908d16
Android SDK: /Users/georgekarabin/Library/Android/sdk
Supported Android versions:
4.4 (API level 19)

When using the "Preview" Update Channel, VS for Mac's "Visual Studio Update" hasn't presented a new version of Xamarin.Android to download for some time.

I was thinking that since you mentioned a private repo that maybe the change went into the VS for Mac binary itself rather than Xamarin.Android and decided not to be too chatty, but if I had to guess the new Xamarin.Android builds are not being pushed to VS for Mac's Update channel.

FWIW, I have noticed that I am getting preview updates of all of the normal things except Xamarin.Android. I've attached the full output of the "About Visual Studio" buffer here: vs-for-mac-version-info.txt.

At one point while I was trying to get my head around a different issue I uninstalled VS for Mac entirely and reinstalled, but the preview channel is still not downloading new Xamarin.Android versions.

They are just on different update schedules. Does the build above solve the problem?

It did - thanks!

@gkarabin I checked up on this, and the final build for Xamarin.Android didn't make it into VS Mac 8.9.

This should hopefully be fixed in the first service release for VS Mac 8.9.

Was this page helpful?
0 / 5 - 0 ratings