Bug 52845

Summary: [Cycle 9] Satellite assemblies not bundled when using "Bundle assemblies into native code" due to "unknown escape sequence" error from gcc during mkbundle step
Product: Android Reporter: Serge <evlentev>
Component: GeneralAssignee: Marek Habersack <grendel>
Status: RESOLVED DUPLICATE    
Severity: major CC: a.dotreppe, AnatoliiB, brendan.zagaeski, bulent, fernandovm, grendel, joas, luis.aguilera, mono-bugs+monodroid, walter.olson
Priority: ---    
Version: 7.1 (C9)   
Target Milestone: C9SR0   
Hardware: PC   
OS: Windows   
Tags: Cycle9R Is this bug a regression?: Yes
Last known good build: Cycle 8 SR 2 (Xamarin.Android 7.0.2.42 (501e63c))
Attachments: Test case (for Android)
Sample app showing satellite assemblies not embedded with 'Bundle assemblies into native code'.

Description Serge 2017-02-27 16:08:03 UTC
Satellite assembly bundling failing in new release and resx localization is not working.

I suggest it happens because mkbundle uses Path.DirectorySeparatorChar in method GetAssemblyName and gcc can't compile it later.

https://github.com/mono/mono/blob/master/mcs/tools/mkbundle/mkbundle.cs

Here is visual studio output:
4>[mkbundle stdout] Generated obj\Release\bundles\x86\temp.c
4>[mkbundle stdout] 
4>[mkbundle stderr] 
4>[CC] "C:\ProgramData\Microsoft\AndroidNDK\android-ndk-r10e\toolchains\x86-4.9\prebuilt\windows\bin\i686-linux-android-gcc.exe" -c -o obj\Release\bundles\x86\temp.o -I C:\ProgramData\Microsoft\AndroidNDK\android-ndk-r10e\platforms\android-9\arch-x86\usr\include obj\Release\bundles\x86\temp.c
4>[cc stderr] obj\Release\bundles\x86\temp.c:213:81: warning: unknown escape sequence: '\F'
4>[cc stderr]  static CompressedAssembly assembly_bundle_ru_FluentValidation_resources_dll = {{"ru\FluentValidation.resources.dll", assembly_data_ru_FluentValidation_resources_dll, 5632}, 1972};
Comment 2 Brendan Zagaeski (Xamarin Support) 2017-03-02 17:20:08 UTC
Non-engineering team preliminary quick review




## Suspected to be a regression or a problem with a new feature?

Yes.  Based on the reporter's description, this seems likely to be a side-effect of some of the various changes to `mkbundle` in Mono 4.8 [1].

[1] http://www.mono-project.com/docs/about-mono/releases/4.8.0/




## Specific to one particular project, development computer, or target mobile device?

It might be specific to Windows and the path separator character.  It seems like in theory it should be fairly easy to reproduce the issue with any satellite assembly test case (such as the test case attached to Bug 15948).  I will plan to try that test case and post back the results in a follow-up comment.




# Already took up time for many users?

Not too many yet, but there is a slowly increasing number of users on CC on the bug, so this is definitely a good bug to monitor and push forward.




## Makes development (a) difficult, impossible, or potentially hazardous, (b) moderately inconvenient, or (c) mildly inconvenient for users?

(a) This issue would prevent further development using satellite assemblies on Android, at least in the described conditions from Comment 0.  There might be a workaround that could be used to move forward temporarily, but the specifics of that have not been worked out yet
Comment 3 Brendan Zagaeski (Xamarin Support) 2017-03-03 02:51:07 UTC
Created attachment 20107 [details]
Test case (for Android)

This does indeed appear to be caused by the new use of `Path.DirectorySeparatorChar()` in the fix for Mono Bug 11430 [1].

[1] https://github.com/mono/mono/commit/787b047886da494ec2f05a2db86baca33a9f39f7


This should in theory affect the test case for Bug 11430 in desktop Mono on Windows too.  I will aim to file a follow-up bug for that shortly.




## Regression status

BAD:  XamarinVS 4.3.1.1   (3b21f70), Xamarin.Android 7.1.99.93 (8943b85)
BAD:  XamarinVS 4.3.0.784 (73f58d6), Xamarin.Android 7.1.0.41  (9578cdc)
GOOD: XamarinVS 4.2.2.11  (00fa5cc), Xamarin.Android 7.0.2.42  (501e63c)




## Steps followed to test

Attempt to build the .apk package for the attached test case in the Release configuration on Windows.  For example, run:

msbuild /p:Configuration=Release /t:SignAndroidPackage I18nResourcesBug\I18nResourcesBug.csproj




## BAD Results with Xamarin.Android 7.1 (and higher)


- The build completes "successfully", but the build produces an incorrect .apk file because the mkbundle process does not succeed for all the satellite assemblies.  Here is a section from the diagnostic build output for this particular test case that matches up approximately with the log excerpt from Comment 0:

> [CC] "C:\android-ndk-r11c\toolchains\arm-linux-androideabi-4.9\prebuilt\windows-x86_64\bin\arm-linux-androideabi-gcc.exe" -c -o obj\Release\bundles\armeabi-v7a\temp.o -I C:\android-ndk-r11c\platforms\android-4\arch-arm\usr\include obj\Release\bundles\armeabi-v7a\temp.c
>   [cc stderr] obj\Release\bundles\armeabi-v7a\temp.c:25:84: warning: unknown escape sequence: '\I'
>   [cc stderr]  static CompressedAssembly assembly_bundle_fr_CA_I18nResourcesBug_resources_dll = {{"fr-CA\I18nResourcesBug.resources.dll", assembly_data_fr_CA_I18nResourcesBug_resources_dll, 3584}, 1204};
>   [cc stderr]                                                                                     ^

- Running the .apk on device or emulator launches successfully, but the string displayed for the "[fr-CA locale]" is incorrect (not localized):

> [Default locale]:
> I18nResourcesBug string in English.

> [fr-CA locale]:
> I18nResourcesBug string in English.



## GOOD Results

- The build completes successfully, _and_ the mkbundle process completes successfully for all assemblies.  In particular, the `gcc` command runs _without_ error:

>   [CC] "C:\android-ndk-r11c\toolchains\arm-linux-androideabi-4.9\prebuilt\windows-x86_64\bin\arm-linux-androideabi-gcc.exe" -c -o obj\Release\bundles\armeabi-v7a\temp.o -I C:\android-ndk-r11c\platforms\android-4\arch-arm\usr\include obj\Release\bundles\armeabi-v7a\temp.c (TaskId:349)
>   [cc stderr]
>   [cc stdout]

- Running the .apk on device or emulator displays the expected strings in the app:

> [Default locale]:
> I18nResourcesBug string in English.

> [fr-CA locale]:
> I18nResourcesBug string in French.



## Testing note for Xamarin.Android 7.1 and lower

Due to Bug 48678, it is necessary to use Android NDK r11c or lower when testing the behavior of `mkbundle` on Xamarin.Android 7.1 and lower.  That limitation is no longer present in Xamarin.Android 7.1.99 (aka 7.2).  (And for the purposes of this particular bug, that limitation is not too important because the results are the same when using either NDK r12 or NDK r11 with Xamarin.Android 7.1.99.)




## Testing environment info

Android NDK r11c (64-bit)
Java JDK 8u121 (64-bit)

Android SDK Tools 25.2.4
Android SDK Platform-tools 25.0.3
Android SDK Build-tools 25.0.2

Microsoft Visual Studio Enterprise 2015
Version 14.0.25431.01 Update 3
Microsoft .NET Framework
Version 4.6.01586

Windows 10 (64-bit) Version 1607 (OS Build 14393.321)
US English locale, US eastern time zone



### Testing device

KitKat (Android 4.4 - API 19) Visual Studio Android Emulator
Comment 4 Brendan Zagaeski (Xamarin Support) 2017-03-03 03:40:03 UTC
> This should in theory affect the test case for Bug 11430 in desktop
> Mono on Windows too.  I will aim to file a follow-up bug for that
> shortly.

On second thought, setting up the environment for testing that on Windows requires setting up some additional tools, and the Android NDK toolchain test scenario might be sufficient as a way to test the candidate fix for this bug, so I'll hold off on the work to set up a separate test case for desktop Mono on Windows for now.
Comment 7 FernandoVM 2017-04-13 21:29:53 UTC
Created attachment 21527 [details]
Sample app showing satellite assemblies not embedded with 'Bundle assemblies into native code'.
Comment 8 FernandoVM 2017-04-13 21:48:27 UTC
I have posted a trivial sample app showing satellite assemblies not embedded with 'Bundle assemblies into native code' option checked using versions bellow:

jdk1.8.0_101 (64-bit)
Ndk: both r11c (64-bit) and r14b (64-bit)
Android SDK 25.0.2

Xamarin   4.4.0.34 (3f99c5a)
Xamarin.iOS   10.8.0.174 (7656cc6)
Xamarin.Android   7.2.0.7 (b16fb82)

Has this bug really been fixed? But the detailed build output not show any mkbundle error, then can be other related error.

If I uncheck 'Bundle assemblies in native code' everything works fine. I need some special version of some tool?
Comment 9 Brendan Zagaeski (Xamarin Support) 2017-04-26 03:03:49 UTC
Thanks for the extra verification attempt in Comment 7 and Comment 8!  Ideally the verification attempt for this exact bug report would be based on the existing test case presented in Comment 3, so I have re-tested that test case and found that indeed it does _not_ behave as expected.

In short, the initial verification of this bug appears to have been incomplete or incorrect.  I have filed a new bug to describe a remaining failure behavior for the test case, steps to replicate, and testing environment as described in Comment 3.  I will mark this bug as a duplicate of that follow-up bug for tracking purposes.

(In case it might come in handy for future reference, note also that in general new bug reports have better visibility to the engineering team compared to comments on Verified Fixed bugs.)

*** This bug has been marked as a duplicate of bug 55603 ***
Comment 10 FernandoVM 2017-04-28 11:43:52 UTC
You are welcome, I'm waiting by good news!