Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Bug] Resx files don't work with Android App Bundle #3596

Closed
DiamondKesha opened this issue Sep 6, 2019 · 20 comments · Fixed by #3603
Closed

[Bug] Resx files don't work with Android App Bundle #3596

DiamondKesha opened this issue Sep 6, 2019 · 20 comments · Fixed by #3603
Assignees
Labels
Area: App+Library Build Issues when building Library projects or Application projects.

Comments

@DiamondKesha
Copy link

Description

If use Android App Bundle, then AppResource.de.resx and other don't work, but AppResource.resx work.
I use - this example

Steps to Reproduce

  1. Add <AndroidPackageFormat>aab</AndroidPackageFormat> in project.csproj

Expected Behavior

Changing the language in the program

Actual Behavior

The language in the program should change, but it does not change.

Basic Information

  • Platform Target Frameworks: 5.0
  • Affected Devices: Samsung
@samhouts samhouts transferred this issue from xamarin/Xamarin.Forms Sep 6, 2019
@losmacko
Copy link

losmacko commented Sep 9, 2019

I have the same issue. Any workaround?

@jonathanpeppers jonathanpeppers self-assigned this Sep 9, 2019
@jonathanpeppers jonathanpeppers added this to the Under Consideration milestone Sep 9, 2019
@jonathanpeppers jonathanpeppers added the Area: App+Library Build Issues when building Library projects or Application projects. label Sep 9, 2019
jonathanpeppers added a commit to jonathanpeppers/xamarin-android that referenced this issue Sep 9, 2019
Fixes: dotnet#3596
Context: https://github.com/google/bundletool/blob/2e9ac4e628a690c0fce402548fe90c747c86533c/src/main/proto/config.proto#L22-L25

We got report of `.resx` files not working with Android App Bundles.

Sure enough, when I tried the sample:

https://docs.microsoft.com/en-us/samples/xamarin/xamarin-forms-samples/usingresxlocalization/

I was not seeing Spanish localization when running the app...

So I pulled the app bundle from the device:

    >  adb shell pm list packages -f | Select-String UsingResxLocalization.Android
    package:/data/app/UsingResxLocalization.Android-VGGyQ6woBTkNUy4HJ8WqmQ==/base.apk=UsingResxLocalization.Android
    > adb pull /data/app/UsingResxLocalization.Android-VGGyQ6woBTkNUy4HJ8WqmQ==/base.apk
    /data/app/UsingResxLocalization.Android-VGGyQ6woBTkNUy4HJ8WqmQ==/base.apk: 1 file pulled. 35.1 MB/s (12330445 bytes in 0.335s)

And then discovered that all of the localization assemblies were
compressed!

    > 7z l base.apk
    ...
    Size  Compressed    Name
    ----- ------------  ------------
    14848        14848  assemblies\UsingResxLocalization.dll
     3584         1279  assemblies\de-CH\UsingResxLocalization.resources.dll
     3584         1275  assemblies\de\UsingResxLocalization.resources.dll
     3584         1306  assemblies\es\UsingResxLocalization.resources.dll
     3584         1273  assemblies\fr\UsingResxLocalization.resources.dll
     3584         1286  assemblies\id\UsingResxLocalization.resources.dll
     3584         1348  assemblies\ja\UsingResxLocalization.resources.dll
     3584         1280  assemblies\ms\UsingResxLocalization.resources.dll
     3584         1302  assemblies\pt-BR\UsingResxLocalization.resources.dll
     3584         1301  assemblies\pt\UsingResxLocalization.resources.dll
     3584         1288  assemblies\zh-Hans\UsingResxLocalization.resources.dll
     3584         1288  assemblies\zh-Hant\UsingResxLocalization.resources.dll

Looking the file structure of the `base.apk`, we had an incorrect
wildcard for `BundleConfig.json`:

    assemblies/*

It needs to be `assemblies/**`, so sub-directories will work.

I added a project with `.resx` files to `BundleToolTests` and some
assertions to ensure all .NET assemblies remain uncompressed in
Android App Bundles.
@jonathanpeppers
Copy link
Member

I did not test this, but a theoretical workaround, would be to set .dll for the AndroidStoreUncompressedFileExtensions setting:

image

jonathanpeppers added a commit that referenced this issue Sep 9, 2019
Fixes: #3596
Context: https://github.com/google/bundletool/blob/2e9ac4e628a690c0fce402548fe90c747c86533c/src/main/proto/config.proto#L22-L25

We got report of `.resx` files not working with Android App Bundles.

Sure enough, when I tried the sample:

https://docs.microsoft.com/en-us/samples/xamarin/xamarin-forms-samples/usingresxlocalization/

I was not seeing Spanish localization when running the app...

So I pulled the app bundle from the device:

    >  adb shell pm list packages -f | Select-String UsingResxLocalization.Android
    package:/data/app/UsingResxLocalization.Android-VGGyQ6woBTkNUy4HJ8WqmQ==/base.apk=UsingResxLocalization.Android
    > adb pull /data/app/UsingResxLocalization.Android-VGGyQ6woBTkNUy4HJ8WqmQ==/base.apk
    /data/app/UsingResxLocalization.Android-VGGyQ6woBTkNUy4HJ8WqmQ==/base.apk: 1 file pulled. 35.1 MB/s (12330445 bytes in 0.335s)

And then discovered that all of the localization assemblies were
compressed!

    > 7z l base.apk
    ...
    Size  Compressed    Name
    ----- ------------  ------------
    14848        14848  assemblies\UsingResxLocalization.dll
     3584         1279  assemblies\de-CH\UsingResxLocalization.resources.dll
     3584         1275  assemblies\de\UsingResxLocalization.resources.dll
     3584         1306  assemblies\es\UsingResxLocalization.resources.dll
     3584         1273  assemblies\fr\UsingResxLocalization.resources.dll
     3584         1286  assemblies\id\UsingResxLocalization.resources.dll
     3584         1348  assemblies\ja\UsingResxLocalization.resources.dll
     3584         1280  assemblies\ms\UsingResxLocalization.resources.dll
     3584         1302  assemblies\pt-BR\UsingResxLocalization.resources.dll
     3584         1301  assemblies\pt\UsingResxLocalization.resources.dll
     3584         1288  assemblies\zh-Hans\UsingResxLocalization.resources.dll
     3584         1288  assemblies\zh-Hant\UsingResxLocalization.resources.dll

Looking the file structure of the `base.apk`, we had an incorrect
wildcard for `BundleConfig.json`:

    assemblies/*

It needs to be `assemblies/**`, so sub-directories will work.

I added a project with `.resx` files to `BundleToolTests` and some
assertions to ensure all .NET assemblies remain uncompressed in
Android App Bundles.
jonpryor pushed a commit that referenced this issue Sep 11, 2019
Fixes: #3596
Context: https://github.com/google/bundletool/blob/2e9ac4e628a690c0fce402548fe90c747c86533c/src/main/proto/config.proto#L22-L25

We got report of `.resx` files not working with Android App Bundles.

Sure enough, when I tried the sample:

https://docs.microsoft.com/en-us/samples/xamarin/xamarin-forms-samples/usingresxlocalization/

I was not seeing Spanish localization when running the app...

So I pulled the app bundle from the device:

    >  adb shell pm list packages -f | Select-String UsingResxLocalization.Android
    package:/data/app/UsingResxLocalization.Android-VGGyQ6woBTkNUy4HJ8WqmQ==/base.apk=UsingResxLocalization.Android
    > adb pull /data/app/UsingResxLocalization.Android-VGGyQ6woBTkNUy4HJ8WqmQ==/base.apk
    /data/app/UsingResxLocalization.Android-VGGyQ6woBTkNUy4HJ8WqmQ==/base.apk: 1 file pulled. 35.1 MB/s (12330445 bytes in 0.335s)

And then discovered that all of the localization assemblies were
compressed!

    > 7z l base.apk
    ...
    Size  Compressed    Name
    ----- ------------  ------------
    14848        14848  assemblies\UsingResxLocalization.dll
     3584         1279  assemblies\de-CH\UsingResxLocalization.resources.dll
     3584         1275  assemblies\de\UsingResxLocalization.resources.dll
     3584         1306  assemblies\es\UsingResxLocalization.resources.dll
     3584         1273  assemblies\fr\UsingResxLocalization.resources.dll
     3584         1286  assemblies\id\UsingResxLocalization.resources.dll
     3584         1348  assemblies\ja\UsingResxLocalization.resources.dll
     3584         1280  assemblies\ms\UsingResxLocalization.resources.dll
     3584         1302  assemblies\pt-BR\UsingResxLocalization.resources.dll
     3584         1301  assemblies\pt\UsingResxLocalization.resources.dll
     3584         1288  assemblies\zh-Hans\UsingResxLocalization.resources.dll
     3584         1288  assemblies\zh-Hant\UsingResxLocalization.resources.dll

Looking the file structure of the `base.apk`, we had an incorrect
wildcard for `BundleConfig.json`:

    assemblies/*

It needs to be `assemblies/**`, so sub-directories will work.

I added a project with `.resx` files to `BundleToolTests` and some
assertions to ensure all .NET assemblies remain uncompressed in
Android App Bundles.
@King-of-Spades
Copy link

@jonathanpeppers Is the fix available yet in a Xamarin.Android release, or is that still pending?

@jonathanpeppers
Copy link
Member

It should be in a future Visual Studio 2019 16.4 release. I don’t think the release date is public quite yet.

@EmilAlipiev
Copy link

Does this solution have any side effects? is it not increasing bundle size? if i am not mistaken dlls were compressed into apk but now not in aab. is it not a step back?

@jonathanpeppers
Copy link
Member

jonathanpeppers commented Sep 23, 2019

DLLs are not compressed, because mmap is used to load them into memory directly from the APK.

I think we looked at allowing .NET assemblies to be compressed at one point, but it hurt startup performance.

@brendanzagaeski
Copy link
Contributor

Release status update

A new Preview version has now been published that includes the fix for this item. The fix is not yet included in a Release version. I will update this item again when a Release version is available that includes the fix.

The fix is not yet available on macOS. I will update this item again when a Preview version with the fix is available on macOS.

Fix included in Xamarin.Android 10.0.99.100.

Fix included on Windows in Visual Studio 2019 version 16.4 Preview 1. To try the Preview version that includes the fix, check for the latest updates in Visual Studio Preview.

Fix not yet available on macOS.

@thisisthekap
Copy link

@brendanzagaeski As we are quite desperately looking forward to AAB publishing (mainly because of download sizes), we would appreciate it to see this issue in a hotfix Version of Xamarin.Android, as this issue is also listed in the "Known Issues" section of Xamarin.Android 10.0.0.43.

@jonathanpeppers
Copy link
Member

@thisisthekap did the workaround work? #3596 (comment)

@mvxproject
Copy link

I Confirm, the workaround works, mp3 files must also be included to work properly.

@jonathanpeppers
Copy link
Member

@lahna200 there are 2 fixes for app bundles & compression in the next release (Xamarin.Android 10.1), but I bet this one will fix the mp3 issue: #3604

@brendanzagaeski
Copy link
Contributor

Release status update

A new Preview version has now been published for macOS that includes the fix for this item.

Fix included in Xamarin.Android 10.1.0.1.

Fix included on macOS in Visual Studio 2019 for Mac version 8.4 Preview 1. To try the Preview version that includes the fix, check for the latest updates on the Preview updater channel.

@EmilAlipiev
Copy link

Is there already a documentation or article about how to achieve app bundles step by step?

@andrewleader
Copy link

I'm also blocked on this, eagerly waiting for the stable channel release fix to hit Azure DevOps so I can build in the cloud again! Building locally using the preview in the meantime.

@jonathanpeppers
Copy link
Member

@andrewleader there is a workaround for this one: #3596 (comment)

@brendanzagaeski
Copy link
Contributor

Release status update

A new Release version has now been published on Windows that includes the fix for this item. The fix is not yet published in a Release version on macOS. I will update this item again when a Release version is available on macOS that includes the fix.

Fix included in Xamarin.Android 10.1.0.30.

Fix included on Windows in Visual Studio 2019 version 16.4. To get the new version that includes the fix, check for the latest updates or install the latest version from https://visualstudio.microsoft.com/downloads/.

(Fix also included on macOS in Visual Studio 2019 for Mac version 8.4 Preview 2.1 and higher. To try the Preview version that includes the fix, check for the latest updates on the Preview updater channel.)

@brendanzagaeski
Copy link
Contributor

Release status update

A new Release version has now been published on macOS that includes the fix for this item.

Fix included in Xamarin.Android 10.1.1.0.

Fix included on macOS in Visual Studio 2019 for Mac version 8.4. To get the new version that includes the fix, check for the latest updates on the Stable updater channel.

(Fix also included on Windows in Visual Studio 2019 version 16.4 and higher. To get the new version that includes the fix, check for the latest updates or install the latest version from https://visualstudio.microsoft.com/downloads/.)

@acuntex
Copy link

acuntex commented May 28, 2020

@brendanzagaeski Does either not work or is a regressed bug.

When starting the app in a German Simulator all texts show correctly in German.
When bundling as aab and uploading to the store all texts are again English on a German device.

Anyone else experiencing this?

@brendanzagaeski
Copy link
Contributor

@acuntex, thanks for the heads-up! If are using Xamarin.Android 10.3 in Visual Studio 2019 version 16.6 or Visual Studio 2019 for Mac version 8.6, one likely possible cause is #4664. If the workaround mentioned in that item does not resolve the issue for your project, then if you might be able to submit a new issue that has the diagnostic MSBuild output from your project zipped and attached so the team can take a look, that would be perfect. Thanks in advance!

@acuntex
Copy link

acuntex commented May 28, 2020

I can confirm that the workaround from #4664 worked.
Thanks!

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Area: App+Library Build Issues when building Library projects or Application projects.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

10 participants