Bug 15022 - Android sample 'Gesture Builder' gives build error with Linker Option "Link ALL" on Release mode
Summary: Android sample 'Gesture Builder' gives build error with Linker Option "Link A...
Status: VERIFIED FIXED
Alias: None
Product: Android
Classification: Xamarin
Component: MSBuild ()
Version: 4.8.x
Hardware: All All
: Normal normal
Target Milestone: ---
Assignee: Atsushi Eno
URL:
Depends on:
Blocks:
 
Reported: 2013-09-26 14:37 UTC by Atin
Modified: 2014-07-04 10:34 UTC (History)
6 users (show)

Tags:
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:
Status:
VERIFIED FIXED

Description Atin 2013-09-26 14:37:11 UTC
Steps to reproduce:
1. Open Gesture builder sample in XS
2. Set the linker option Link All.
3. Build the application

Actual result:
Application gives build error with options Link All, no shared, no fast. however its working fine with Don't link and link SDK assemblies options.

Build output: https://gist.github.com/atin360/7bd9beed8d21528580cd

Expected result:
Application should build successfully with Link All, no shared , no fast option.

Environment details:
Mac ML 10.8.5
Window 7
VS 2010/12
XS 4.0.13(build 39)
MFA 4.8.03003

Regression Status: This issue also exists with stable environment XS 4.0.12(build3), MFA 4.8.1-13-1 and Mono 3.2.3

App info: monodroid-samples-master-1e10e2cf956940cbaa0dcafd9b95d7ac97a58c2e
Comment 1 Peter Collins 2013-09-26 15:55:44 UTC
Not sure why there's a complaint about Mono.Android.Export.dll in this particular case, the .dll definitely exists in the reference assemblies dir.
Comment 2 Jonathan Pryor 2013-09-26 17:11:33 UTC
I suspect that it's because we use post-linking assembly references to determine what goes into the .apk/etc., and since Mono.Android.Export.dll exports no types all inclusions of the assembly are removed, resulting in pain & sadness.

Clearly we need to special-case Mono.Android.Export.dll somewhere.
Comment 3 Atsushi Eno 2014-01-16 02:06:23 UTC
pjbeaman: jonp's assignment is correct, it's more about msbuild issue than samples issue.
Comment 4 Atsushi Eno 2014-02-05 04:04:14 UTC
This does not launch, due to some runtime crash:

[mono-rt] Stacktrace:
[mono-rt] 
In mgmain JNI_OnLoad
[mono-rt]   at <unknown> <0xffffffff>
[mono-rt]   at <unknown> <0xffffffff>
[mono-rt]   at (wrapper managed-to-native) System.Diagnostics.Debugger.Mono_UnhandledException_internal (System.Exception) <IL 0x00021, 0xffffffff>
[mono-rt]   at System.Diagnostics.Debugger.Mono_UnhandledException (System.Exception) <IL 0x00001, 0x00027>
[mono-rt]   at (wrapper dynamic-method) object.ab2cd458-8304-4bf5-84fb-45c55f0e3672 (intptr,intptr,intptr) <IL 0x00026, 0x00037>
[mono-rt]   at (wrapper native-to-managed) object.ab2cd458-8304-4bf5-84fb-45c55f0e3672 (intptr,intptr,intptr) <IL 0x00023, 0xffffffff>


https://gist.github.com/atsushieno/46eba445fbe32c301703

Assign it back to me once the runtime gets resolved.
Comment 5 Jonathan Pryor 2014-02-05 11:36:04 UTC
Eno: As per the original description, this is a _build_ bug, not (yet) a runtime bug. If you can run the app, you're not reproducing it properly.

To reproduce in more precise form:

1. Clone monodroid-samples

2. Edit GestureBuilder/GestureBuilder/GestureBuilder.csproj. In the Release|AnyCPU section, change <AndroidLinkMode/> to:

    <AndroidLinkMode>Full</AndroidLinkMode>

3. Build in Release configuration:

    xbuild /t:SignAndroidPackage /p:Configuration=Release *.csproj

Expected result: it should actually build.

Actual results: it doesn't:

> 	: error XA4210: You need to add a reference to Mono.Android.Export.dll when you use ExportAttribute or ExportFieldAttribute.

Furthermore, if you read GestureBuilder.csproj, you will see the Mono.Android.Export _is_ referenced, and thus the error message is wrong:

    <Reference Include="Mono.Android.Export" />

Furthermore, once the above build issue is fixed, you will _at minimum_ need to verify that the Mono.Android.Export.dll included in the .apk is UNLINKED. Linking Mono.Android.Export.dll will result in nothing working properly.

Once it builds and Mono.Android.Export is unlinked, _then_ we can investigate runtime errors.
Comment 6 Atsushi Eno 2014-02-05 11:49:36 UTC
Let's be practical and think why we need this running fine _regardless of the linking mode_. It is mandatory to know whether the app runs regardless of whether it is linking or not. As I mentioned, currently it does NOT. I cannot distinguish if the app startup crasher I'd be seeing is caused either by the missing dll glitch or other runtime issue, and thus I may have to keep investigate in wrong part i.e. that runtime issue prevents further investigation.
Comment 7 Atsushi Eno 2014-02-05 11:50:33 UTC
Besides, as I mentioned elsewhere, the same problem occurs on other bugs (e.g. bug #16805).
Comment 8 Jonathan Pryor 2014-02-05 12:27:32 UTC
> As I mentioned, currently it does NOT.

I can't repro your crash. How are you getting the startup crash?

Is it a Debug build? (Works for me!) Release build? (Doesn't build for me!) Do you have some private patches applied?

Furthermore, the JNI_OnLoad() crash doesn't make any sense at all, as libmonodroid.so!JNI_OnLoad() doesn't call into managed code (it can't!), so  why is JNI_OnLoad() mentioned at all?

You may want to use our new gdb support, and get a "proper" stack trace: http://docs.xamarin.com/guides/android/advanced_topics/gdb/

Finally, Bug #16805 doesn't mention any startup crash, much less one within JNI_OnLoad() similar to Comment #4.
Comment 10 Atsushi Eno 2014-02-06 15:16:15 UTC
Figured out how come the results are different, filed as https://bugzilla.xamarin.com/show_bug.cgi?id=17645

Hence reassigning the bug back to myself (at the state of comment #3).
Comment 11 Atsushi Eno 2014-02-18 05:17:32 UTC
This should be now fixed. [master 6e32913]
Comment 12 Tajinder Singh 2014-03-26 10:17:16 UTC
Today I have checked this issue with the following builds by selecting option link all:

XS 4.2.4(build 32)
X.Android 4.12.3

Now application builds successfully on windows and MAC.Hence verifying this issue.
Comment 13 Jonathan Pryor 2014-04-17 15:42:17 UTC
@Tajinder: What's the full version that you verified with?

Did you verify with a Release or a Debug build?

Building GestureBuilder in Release configuration fails for me with 4.12.3.133227475 (4.12.3-3):

$ sed -i '' 's/>SdkOnly</>Full</g' GestureBuilder.csproj
$ xbuild /t:SignAndroidPackage /p:Configuration=Release
...
: error XA4210: You need to add a reference to Mono.Android.Export.dll when you use ExportAttribute or ExportFieldAttribute.


It shouldn't fail with $(AndroidLinkMode)='Full' ("Link All Assemblies"), yet it does.
Comment 14 Jonathan Pryor 2014-04-17 15:55:21 UTC
monodroid/6e32913 does contain the fix, but the fix is not in monodroid-4.12-series. The fix will be in the Xamarin.Android 4.14 series.
Comment 15 Atin 2014-06-02 14:38:30 UTC
Today, I have tried to verify this issue with:
XS 5.1(build 307)
X.Android 4.14.0-9

But, I am getting another error while verifying this  issue. So I have reported another Bug 20278 for the same.
Comment 16 Danish Akhtar 2014-07-04 10:34:46 UTC
Today, I have tried to verify this issue with:
XS 5.2(build 179)
X.Android 4.14.0-45

I am not getting build error, application is build successfully in release mode with Link All option. Hence closing this issue.

but I am getting another issue for this application for which I have filed Bug 21126