Bug 10771 - MakeBundleNativeCodeExternal task is broken
Summary: MakeBundleNativeCodeExternal task is broken
Alias: None
Product: Android
Classification: Xamarin
Component: MSBuild ()
Version: 4.6.x
Hardware: PC Mac OS
: Highest normal
Target Milestone: ---
Assignee: Atsushi Eno
: 10867 ()
Depends on:
Blocks: 10865
  Show dependency tree
Reported: 2013-02-28 11:30 UTC by Jonathan Pryor
Modified: 2013-06-11 09:30 UTC (History)
9 users (show)

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

Notice (2018-05-24): bugzilla.xamarin.com is now in read-only mode.

Please join us on Visual Studio Developer Community and in the Xamarin and Mono organizations on GitHub to continue tracking issues. Bugzilla will remain available for reference in read-only mode. We will continue to work on open Bugzilla bugs, copy them to the new locations as needed for follow-up, and add the new items under Related Links.

Our sincere thanks to everyone who has contributed on this bug tracker over the years. Thanks also for your understanding as we make these adjustments and improvements for the future.

Please create a new report on Developer Community or GitHub with your current version information, steps to reproduce, and relevant error messages or log files if you are hitting an issue that looks similar to this resolved bug and you do not yet see a matching new report.

Related Links:

Description Jonathan Pryor 2013-02-28 11:30:27 UTC
Context: http://forums.xamarin.com/discussion/1744/create-package-in-xs#latest

Steps to reproduce:

1. Create a new project.
2. Switch Configuration to Release
3. Edit the Project Options/Properties
3.a: XS: Build > Android Build > [X] Bundle assemblies into native code
3.b: VS: Mono Android Options > [X] Bundle assemblies into native code
3.b.i: note: Bug #10768
4. Build + Run project. Build fails.

Unfortunately (due to Bug #10770) we don't see the mkbundle output & errors, so let's hit the command-line:

> $ xbuild /t:SignAndroidPackage /p:Configuration=Release /v:diag *.csproj > build.txt 2>&1

build.txt contains the error:

> 	Task "MakeBundleNativeCodeExternal"
> 		Using task MakeBundleNativeCodeExternal from Xamarin.Android.Tasks.MakeBundleNativeCodeExternal, Xamarin.Android.Build.Tasks, Version=, Culture=neutral, PublicKeyToken=null
> 		Assemblies: 6
> 		SupportedAbis: armeabi-v7a
> 		AutoDeps: False
> 		[mkbundle] /usr/bin/mkbundle --nomain -c -o obj/Release/bundles/armeabi-v7a/temp.c -oo obj/Release/bundles/armeabi-v7a/assemblies.o obj/Release/android/assets/Scratch.Junk.dll obj/Release/android/assets/shrunk/Mono.Android.dll obj/Release/android/assets/shrunk/mscorlib.dll obj/Release/android/assets/shrunk/System.Core.dll obj/Release/android/assets/shrunk/System.dll obj/Release/android/assets/shrunk/Mono.Security.dll
> OS is: Darwin
> Sources: 6 Auto-dependencies: False
>    embedding: /Users/jon/Development/Projects/Scratch.Junk/obj/Release/android/assets/Scratch.Junk.dll
>    embedding: /Users/jon/Development/Projects/Scratch.Junk/obj/Release/android/assets/shrunk/Mono.Android.dll
>    embedding: /Library/Frameworks/Mono.framework/Versions/2.10.11/lib/mono/4.0/mscorlib.dll
>    embedding: /Users/jon/Development/Projects/Scratch.Junk/obj/Release/android/assets/shrunk/System.Core.dll
>    embedding: /Users/jon/Development/Projects/Scratch.Junk/obj/Release/android/assets/shrunk/System.dll
>    embedding: /Users/jon/Development/Projects/Scratch.Junk/obj/Release/android/assets/shrunk/Mono.Security.dll
> Compiling:
> /opt/android/ndk/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 
> temp.s: Assembler messages:
> temp.s:1: Error: character following name is not '#'
> temp.s:7176: Error: character following name is not '#'
> temp.s:477199: Error: character following name is not '#'
> temp.s:3349526: Error: character following name is not '#'
> temp.s:3361309: Error: character following name is not '#'
> temp.s:3846692: Error: character following name is not '#'
> [Fail]

The assembly we're generating is not liked by Android NDK's arm-linux-androideabi-as.
Comment 4 PJ 2013-03-04 10:46:45 UTC
*** Bug 10867 has been marked as a duplicate of this bug. ***
Comment 9 Jonathan Pryor 2013-03-28 10:14:33 UTC
Related: the mkbundle process needs to be updated to account for satellite assemblies; see also Bug #5037 and monodroid/5cedcf01.
Comment 14 Atsushi Eno 2013-05-31 05:15:41 UTC
Windows mkbundle now works too. [master 670500f]
Comment 15 Jonathan Pryor 2013-06-03 21:38:44 UTC
Build fails for me on Windows. Looks to be due to a program quoting issue:

> Task "MakeBundleNativeCodeExternal" (TaskId:272)
>   Task Parameter:AndroidNdkDirectory=C:\Program Files\Android\ndk\android-ndk-r8d\ (TaskId:272)
>   Task Parameter:
>       Assemblies=
>           obj\Release\android\assets\Scratch.Mkbundle.dll
>           obj\Release\android\assets\BundledLib.dll
>           obj\Release\android\assets\shrunk\Mono.Android.dll
>           obj\Release\android\assets\shrunk\mscorlib.dll
>           obj\Release\android\assets\shrunk\System.dll
>           obj\Release\android\assets\shrunk\Mono.Security.dll
>           obj\Release\android\assets\shrunk\System.Core.dll (TaskId:272)
>   Task Parameter:SupportedAbis=armeabi-v7a (TaskId:272)
>   Task Parameter:TempOutputPath=obj\Release\ (TaskId:272)
>   Assemblies: 7 (TaskId:272)
>   SupportedAbis: armeabi-v7a (TaskId:272)
>   AutoDeps: False (TaskId:272)
>   Business (TaskId:272)
>   CC=C:\Program Files\Android\ndk\android-ndk-r8d\toolchains\arm-linux-androideabi-4.4.3\prebuilt\windows\bin\arm-linux-androideabi-gcc.exe (TaskId:272)
>   AS=C:\Program Files\Android\ndk\android-ndk-r8d\toolchains\arm-linux-androideabi-4.4.3\prebuilt\windows\bin\arm-linux-androideabi-as.exe (TaskId:272)
>   [mkbundle] C:\Program Files (x86)\MSBuild\Xamarin\Android\mkbundle.exe --nomain --style linux -c -o obj\Release\bundles\armeabi-v7a\temp.c -oo obj\Release\bundles\armeabi-v7a\assemblies.o obj\Release\android\assets\Scratch.Mkbundle.dll obj\Release\android\assets\BundledLib.dll obj\Release\android\assets\shrunk\Mono.Android.dll obj\Release\android\assets\shrunk\mscorlib.dll obj\Release\android\assets\shrunk\System.dll obj\Release\android\assets\shrunk\Mono.Security.dll obj\Release\android\assets\shrunk\System.Core.dll (TaskId:272)
>   [mkbundle stdout] OS is: Windows (TaskId:272)
>   [mkbundle stdout] Sources: 7 Auto-dependencies: False (TaskId:272)
>   [mkbundle stdout]    embedding: E:\Development\Projects\Scratch.Mkbundle\Scratch.Mkbundle\obj\Release\android\assets\Scratch.Mkbundle.dll (TaskId:272)
>   [mkbundle stdout]    embedding: E:\Development\Projects\Scratch.Mkbundle\Scratch.Mkbundle\obj\Release\android\assets\BundledLib.dll (TaskId:272)
>   [mkbundle stdout]    embedding: E:\Development\Projects\Scratch.Mkbundle\Scratch.Mkbundle\obj\Release\android\assets\shrunk\Mono.Android.dll (TaskId:272)
>   [mkbundle stdout]    embedding: E:\Development\Projects\Scratch.Mkbundle\Scratch.Mkbundle\obj\Release\android\assets\shrunk\System.dll (TaskId:272)
>   [mkbundle stdout]    embedding: E:\Development\Projects\Scratch.Mkbundle\Scratch.Mkbundle\obj\Release\android\assets\shrunk\Mono.Security.dll (TaskId:272)
>   [mkbundle stdout]    embedding: E:\Development\Projects\Scratch.Mkbundle\Scratch.Mkbundle\obj\Release\android\assets\shrunk\System.Core.dll (TaskId:272)
>   [mkbundle stdout]    embedding: E:\Development\Projects\Scratch.Mkbundle\Scratch.Mkbundle\obj\Release\android\assets\shrunk\mscorlib.dll (TaskId:272)
>   [mkbundle stdout] Compiling: (TaskId:272)
>   [mkbundle stdout] C:\Program Files\Android\ndk\android-ndk-r8d\toolchains\arm-linux-androideabi-4.4.3\prebuilt\windows\bin\arm-linux-androideabi-as.exe -o obj\Release\bundles\armeabi-v7a\assemblies.o temp.s  (TaskId:272)
>   [mkbundle stderr] 'C:\Program' is not recognized as an internal or external command, (TaskId:272)
>   [mkbundle stderr] operable program or batch file. (TaskId:272)
>   [mkbundle stderr] [Fail] (TaskId:272)
>   [mkbundle stderr]  (TaskId:272)
>   [mkbundle stdout]  (TaskId:272)
> C:\Program Files (x86)\MSBuild\Xamarin\Android\Xamarin.Android.Common.targets(1180,3): error XA5102: Conversion from assembly to native code failed. Exit code 1 [E:\Development\Projects\Scratch.Mkbundle\Scratch.Mkbundle\Scratch.Mkbundle.csproj]

In particular this line:

>  'C:\Program' is not recognized as an internal or external command
Comment 16 Atsushi Eno 2013-06-03 21:53:00 UTC
That is not likely to happen with the latest installer's default setup. But that is a bug.
Comment 17 Atsushi Eno 2013-06-04 03:02:05 UTC
The path issue is also fixed. Also it should now work with 64bit NDKs. [master f449689]
Comment 18 narayanp 2013-06-10 10:44:41 UTC
Today we have checked this issue with following builds:

All Windows and Mac
X.S 4.0.9(build 3)
Xamarin.Android 4.7.7-24

We observed that when we check "Embed assemblies in native code" checkbox in Project option->Android Build and click ok button and again go to project option and see the changed Android Build under project option then checked box displayed as unchecked. this is the screencast for the same: http://screencast.com/t/PYCaPXMQ

Hence reopening this issue
Comment 19 Peter Collins 2013-06-10 17:45:10 UTC
@narayanp what entitlements did you test against? I am seeing this behavior with starter and indie entitlements, as this feature requires Business or higher entitlements. I have refiled Comment 18 as an enhancement (Bug 12626), we should likely trigger the upgrade workflow when attempting to enable this business feature with low level entitlements.
Comment 20 Nischal 2013-06-11 06:41:41 UTC
We have checked this with Business/Priority and we are able to enable "Embed assemblies in native code" under project option and project build successfully but we are not able to debug/run the application on Mac for which we have reported another issue Bug 12628 

Changing the status of this bug to Verified.