Bug 15948 - "Symbol ... is already defined" error with "Embed assemblies in native code" and multiple .resx files
Summary: "Symbol ... is already defined" error with "Embed assemblies in native code" ...
Status: VERIFIED FIXED
Alias: None
Product: Android
Classification: Xamarin
Component: MSBuild (show other bugs)
Version: 4.10.1
Hardware: PC Mac OS
: High normal
Target Milestone: 7.1 (C9)
Assignee: Jonathan Pryor
URL:
: 19734 24397 27061 (view as bug list)
Depends on: 11430
Blocks:
  Show dependency tree
 
Reported: 2013-11-05 19:41 UTC by Brendan Zagaeski (Xamarin Support)
Modified: 2017-01-13 15:33 UTC (History)
5 users (show)

See Also:
Tags:
Is this bug a regression?: ---
Last known good build:


Attachments
Test case (27.70 KB, application/zip)
2013-11-05 19:41 UTC, Brendan Zagaeski (Xamarin Support)
Details

Description Brendan Zagaeski (Xamarin Support) 2013-11-05 19:41:21 UTC
Created attachment 5342 [details]
Test case

Reported on behalf of a user.

## Steps to reproduce

1. Open attached test project. This is simply the test solution from bug #13438 with the "strings.fr-CA.resx" file duplicated into a "strings.fr-FR.resx" in both projects.

2. Attempt to deploy in Release mode with "Embed assemblies in native code" enabled. (Or run the xbuild SignAndroidPackage target as in Bug #10771)



## Result

The satellite assemblies generated from the "duplicate" .resx files cause a conflict during native compilation.



## Abridged output

> Target _BuildApkBundle:
> 	[mkbundle stdout]    embedding: ~/Projects/I18nResourcesBug/I18nResourcesBug/obj/Release/android/assets/I18nResourcesBug.dll
> 	[mkbundle stdout]    embedding: ~/Projects/I18nResourcesBug/I18nResourcesBug/obj/Release/android/assets/MyResources.dll
> 	[mkbundle stdout]    embedding: ~/Projects/I18nResourcesBug/I18nResourcesBug/bin/Release/fr-CA/I18nResourcesBug.resources.dll
> 	[mkbundle stdout]    embedding: ~/Projects/I18nResourcesBug/I18nResourcesBug/bin/Release/fr-FR/I18nResourcesBug.resources.dll
> 	[mkbundle stdout]    embedding: ~/Projects/I18nResourcesBug/MyResources/bin/Release/fr-CA/MyResources.resources.dll
> 	[mkbundle stdout]    embedding: ~/Projects/I18nResourcesBug/MyResources/bin/Release/fr-FR/MyResources.resources.dll
> 	[mkbundle stdout] Compiling:
> 	[mkbundle stdout] "~/android-ndk-r8d/toolchains/arm-linux-androideabi-4.4.3/prebuilt/darwin-x86/bin/arm-linux-androideabi-as" -o obj/Release/bundles/armeabi-v7a/assemblies.o temp.s 
>	[mkbundle stderr] temp.s: Assembler messages:
>	[mkbundle stderr] temp.s:446: Error: symbol `assembly_data_I18nResourcesBug_resources_dll' is already defined
>	[mkbundle stderr] temp.s:534: Error: symbol `assembly_data_MyResources_resources_dll' is already defined
>	[mkbundle stderr] [Fail]



## Version information

Tested on Xamarin.Android 4.8.3, and 4.10.1
Comment 4 Jonathan Pryor 2014-05-30 23:46:24 UTC
*** Bug 19734 has been marked as a duplicate of this bug. ***
Comment 7 Atsushi Eno 2014-07-30 11:03:47 UTC
It still exists.
Comment 8 Atsushi Eno 2014-12-03 02:16:27 UTC
*** Bug 24397 has been marked as a duplicate of this bug. ***
Comment 9 Brendan Zagaeski (Xamarin Support) 2017-01-13 02:44:16 UTC
## Status and bookkeeping update

The fix for this issue was prepared and recorded on non-public Bug 27061.  The new version of `mkbundle` that includes the fix is now available in the current Cycle 9 Beta version of Xamarin.Android.


Fixed on mono/master: https://github.com/mono/mono/commit/787b047886da494ec2f05a2db86baca33a9f39f7

Backported to mono/mono-4.8.0-branch, commit af086b0c70e4742669618b120b5a9681218e9fbd




## Verification status: verified fixed in Xamarin.Android 7.1 (Cycle 9)



### GOOD results with Xamarin.Android 7.1.0-19 (Cycle 9 Beta from January 10, 2017)

1. The `MakeBundleNativeCodeExternal` task runs to completion without error, and the rest of the build also completes without error.

> 	Task "MakeBundleNativeCodeExternal"
> 		Using task MakeBundleNativeCodeExternal from Xamarin.Android.Tasks.MakeBundleNativeCodeExternal, Xamarin.Android.Build.Tasks, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null
> 		Assemblies: 12
> 		SupportedAbis: armeabi-v7a
> 		AutoDeps: False
> 		CC="/Users/macuser/Library/Developer/Xamarin/android-ndk/android-ndk-r10d/toolchains/arm-linux-androideabi-4.9/prebuilt/darwin-x86_64/bin/arm-linux-androideabi-gcc"
> 		AS="/Users/macuser/Library/Developer/Xamarin/android-ndk/android-ndk-r10d/toolchains/arm-linux-androideabi-4.9/prebuilt/darwin-x86_64/bin/arm-linux-androideabi-as"
> 		[mkbundle] /Library/Frameworks/Xamarin.Android.framework/Versions/Current/lib/mandroid/mkbundle.exe --dos2unix=false --nomain --i18n none --style linux -c -o obj/Release/bundles/armeabi-v7a/temp.c -oo obj/Release/bundles/armeabi-v7a/assemblies.o -z obj/Release/android/assets/I18nResourcesBug.dll obj/Release/android/assets/MyResources.dll /Users/Shared/Projects/MultipleResxError/I18nResourcesBug/bin/Release/fr-CA/I18nResourcesBug.resources.dll /Users/Shared/Projects/MultipleResxError/I18nResourcesBug/bin/Release/fr-FR/I18nResourcesBug.resources.dll /Users/Shared/Projects/MultipleResxError/MyResources/bin/Release/fr-CA/MyResources.resources.dll /Users/Shared/Projects/MultipleResxError/MyResources/bin/Release/fr-FR/MyResources.resources.dll obj/Release/android/assets/shrunk/System.dll obj/Release/android/assets/shrunk/System.Core.dll obj/Release/android/assets/shrunk/Mono.Android.dll obj/Release/android/assets/shrunk/Java.Interop.dll obj/Release/android/assets/shrunk/mscorlib.dll obj/Release/android/assets/shrunk/System.Runtime.Serialization.dll
> 		[mkbundle stdout] Storing satellite assembly '/Users/Shared/Projects/MultipleResxError/I18nResourcesBug/bin/Release/fr-CA/I18nResourcesBug.resources.dll' with name 'fr-CA/I18nResourcesBug.resources.dll'
> 		[mkbundle stdout] Storing satellite assembly '/Users/Shared/Projects/MultipleResxError/I18nResourcesBug/bin/Release/fr-FR/I18nResourcesBug.resources.dll' with name 'fr-FR/I18nResourcesBug.resources.dll'
> 		[mkbundle stdout] Storing satellite assembly '/Users/Shared/Projects/MultipleResxError/MyResources/bin/Release/fr-CA/MyResources.resources.dll' with name 'fr-CA/MyResources.resources.dll'
> 		[mkbundle stdout] Storing satellite assembly '/Users/Shared/Projects/MultipleResxError/MyResources/bin/Release/fr-FR/MyResources.resources.dll' with name 'fr-FR/MyResources.resources.dll'
> 		[mkbundle stdout] Storing satellite assembly '/Users/Shared/Projects/MultipleResxError/I18nResourcesBug/bin/Release/fr-CA/I18nResourcesBug.resources.dll' with name 'fr-CA/I18nResourcesBug.resources.dll'
> 		[mkbundle stdout] Storing satellite assembly '/Users/Shared/Projects/MultipleResxError/I18nResourcesBug/bin/Release/fr-FR/I18nResourcesBug.resources.dll' with name 'fr-FR/I18nResourcesBug.resources.dll'
> 		[mkbundle stdout] Storing satellite assembly '/Users/Shared/Projects/MultipleResxError/MyResources/bin/Release/fr-CA/MyResources.resources.dll' with name 'fr-CA/MyResources.resources.dll'
> 		[mkbundle stdout] Storing satellite assembly '/Users/Shared/Projects/MultipleResxError/MyResources/bin/Release/fr-FR/MyResources.resources.dll' with name 'fr-FR/MyResources.resources.dll'
> 		[mkbundle stdout] Generated obj/Release/bundles/armeabi-v7a/temp.c
> 		[mkbundle stdout] 
> 		[mkbundle stderr] 
> 		[CC] "/Users/macuser/Library/Developer/Xamarin/android-ndk/android-ndk-r10d/toolchains/arm-linux-androideabi-4.9/prebuilt/darwin-x86_64/bin/arm-linux-androideabi-gcc" -c -o obj/Release/bundles/armeabi-v7a/temp.o -I /Users/macuser/Library/Developer/Xamarin/android-ndk/android-ndk-r10d/platforms/android-4/arch-arm/usr/include obj/Release/bundles/armeabi-v7a/temp.c
> 		[cc stderr] 
> 		[cc stdout] 
> 		[LD] /Users/macuser/Library/Developer/Xamarin/android-ndk/android-ndk-r10d/toolchains/arm-linux-androideabi-4.9/prebuilt/darwin-x86_64/bin/arm-linux-androideabi-ld --shared obj/Release/bundles/armeabi-v7a/temp.o obj/Release/bundles/armeabi-v7a/assemblies.o -o obj/Release/bundles/armeabi-v7a/libmonodroid_bundle_app.so -L /Users/macuser/Library/Developer/Xamarin/android-ndk/android-ndk-r10d/platforms/android-4/arch-arm/usr/lib -lc -lm -ldl -llog -lz
> 		[ld stdout] 
> 		[ld stderr] 
> 	Done executing task "MakeBundleNativeCodeExternal"

2. The application launches successfully and the displayed strings for "Default locale" and "fr-CA locale" match the desired values from the 2 separate .resx files.



### BAD results with Xamarin.Anroid 7.0.2-42 (Cycle 8 Service Release 2 from December 22, 2016)

The build fails during the `MakeBundleNativeCodeExternal` target.  The error is in some ways similar to the original from Comment 0, but `mkbundle` has evolved since the original report so that now it detects the unsupported duplicate assembly names earlier in the process and aborts with an error that lists the conflicting names.

> 	Task "MakeBundleNativeCodeExternal"
> 		Using task MakeBundleNativeCodeExternal from Xamarin.Android.Tasks.MakeBundleNativeCodeExternal, Xamarin.Android.Build.Tasks, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null
> 		Assemblies: 14
> 		SupportedAbis: armeabi-v7a
> 		AutoDeps: False
> 		CC="/Users/macuser/Library/Developer/Xamarin/android-ndk/android-ndk-r10d/toolchains/arm-linux-androideabi-4.9/prebuilt/darwin-x86_64/bin/arm-linux-androideabi-gcc"
> 		AS="/Users/macuser/Library/Developer/Xamarin/android-ndk/android-ndk-r10d/toolchains/arm-linux-androideabi-4.9/prebuilt/darwin-x86_64/bin/arm-linux-androideabi-as"
> 		[mkbundle] /Library/Frameworks/Xamarin.Android.framework/Versions/Current/lib/mandroid/mkbundle.exe --dos2unix=false --nomain --style linux -c -o obj/Release/bundles/armeabi-v7a/temp.c -oo obj/Release/bundles/armeabi-v7a/assemblies.o -z obj/Release/android/assets/I18nResourcesBug.dll obj/Release/android/assets/MyResources.dll /Users/Shared/Projects/MultipleResxError/I18nResourcesBug/bin/Release/fr-CA/I18nResourcesBug.resources.dll /Users/Shared/Projects/MultipleResxError/I18nResourcesBug/bin/Release/fr-FR/I18nResourcesBug.resources.dll /Users/Shared/Projects/MultipleResxError/MyResources/bin/Release/fr-CA/MyResources.resources.dll /Users/Shared/Projects/MultipleResxError/MyResources/bin/Release/fr-FR/MyResources.resources.dll obj/Release/android/assets/shrunk/System.dll obj/Release/android/assets/shrunk/System.Xml.dll obj/Release/android/assets/shrunk/System.Core.dll obj/Release/android/assets/shrunk/Mono.Android.dll obj/Release/android/assets/shrunk/Java.Interop.dll obj/Release/android/assets/shrunk/mscorlib.dll obj/Release/android/assets/shrunk/System.Runtime.Serialization.dll obj/Release/android/assets/shrunk/System.ServiceModel.Internals.dll
> 		[mkbundle stdout] OS is: Darwin
> 		[mkbundle stdout] Sources: 14 Auto-dependencies: False
> 		[mkbundle stderr] ERROR: Duplicate assembly name `I18nResourcesBug.resources.dll'. Both `/Users/Shared/Projects/MultipleResxError/I18nResourcesBug/bin/Release/fr-FR/I18nResourcesBug.resources.dll' and `/Users/Shared/Projects/MultipleResxError/I18nResourcesBug/bin/Release/fr-CA/I18nResourcesBug.resources.dll' use same assembly name.
> 		[mkbundle stderr] 
> 		[mkbundle stdout] 
> : error XA5102: Conversion from assembly to native code failed. Exit code 1
> 	Task "MakeBundleNativeCodeExternal" execution -- FAILED



## Additional testing environment info (brief)

Mono 4.8.0 (mono-4.8.0-branch/9e8f0ee)

Mac OS 10.11.6
Comment 10 Peter Collins 2017-01-13 15:33:31 UTC
*** Bug 27061 has been marked as a duplicate of this bug. ***

Note You need to log in before you can comment on or make changes to this bug.