Bug 52940 - Building sample Android project with 'link all' dies with exception: Caused by: android.runtime.JavaProxyThrowable: System.NullReferenceException: Object reference not set to an instance of an object
Summary: Building sample Android project with 'link all' dies with exception: Caused b...
Status: CONFIRMED
Alias: None
Product: Android
Classification: Xamarin
Component: Linker ()
Version: unspecified
Hardware: PC Mac OS
: --- normal
Target Milestone: ---
Assignee: Radek Doulik
URL:
Depends on:
Blocks:
 
Reported: 2017-03-01 19:46 UTC by James Moore
Modified: 2017-06-27 17:43 UTC (History)
3 users (show)

Tags: Cycle9R, bb
Is this bug a regression?: No
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 for Bug 52940 on Developer Community or GitHub if you have new information to add and do not yet see a matching new report.

If the latest results still closely match this report, you can use the original description:

  • Export the original title and description: Developer Community HTML or GitHub Markdown
  • Copy the title and description into the new report. Adjust them to be up-to-date if needed.
  • Add your new information.

In special cases on GitHub you might also want the comments: GitHub Markdown with public comments

Related Links:
Status:
CONFIRMED

Description James Moore 2017-03-01 19:46:24 UTC
Visual Studio for Mac, create new solution, choose Android > App > F#.  Turn on Android Build > Linker > Link all assemblies.

Run.  Push the button.  Get the following crash:


03-01 11:35:32.304 16188 16188 E AndroidRuntime: Process: com.example.sprintfbug, PID: 16188
03-01 11:35:32.304 16188 16188 E AndroidRuntime: java.lang.RuntimeException: java.lang.reflect.InvocationTargetException
03-01 11:35:32.304 16188 16188 E AndroidRuntime: 	at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:755)
03-01 11:35:32.304 16188 16188 E AndroidRuntime: Caused by: java.lang.reflect.InvocationTargetException
03-01 11:35:32.304 16188 16188 E AndroidRuntime: 	at java.lang.reflect.Method.invoke(Native Method)
03-01 11:35:32.304 16188 16188 E AndroidRuntime: 	at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:865)
03-01 11:35:32.304 16188 16188 E AndroidRuntime: 	... 1 more
03-01 11:35:32.304 16188 16188 E AndroidRuntime: Caused by: android.runtime.JavaProxyThrowable: System.NullReferenceException: Object reference not set to an instance of an object
03-01 11:35:32.304 16188 16188 E AndroidRuntime:   at Microsoft.FSharp.Core.PrintfImpl+PrintfBuilder`3[S,TRe,TRes].buildPlainFinal (System.Object[] args, System.Type[] argTypes) [0x00036] in <67b134d6092b4965bbed31dc4c300383>:0 
03-01 11:35:32.304 16188 16188 E AndroidRuntime:   at Microsoft.FSharp.Core.PrintfImpl+PrintfBuilder`3[S,TRe,TRes].buildPlain[a] (System.Int32 numberOfArgs, a prefix) [0x000ac] in <67b134d6092b4965bbed31dc4c300383>:0 
03-01 11:35:32.304 16188 16188 E AndroidRuntime:   at Microsoft.FSharp.Core.PrintfImpl+PrintfBuilder`3[S,TRe,TRes].parseFormatString (System.String s, System.Type funcTy) [0x00060] in <67b134d6092b4965bbed31dc4c300383>:0 
03-01 11:35:32.304 16188 16188 E AndroidRuntime:   at Microsoft.FSharp.Core.PrintfImpl+PrintfBuilder`3[S,TRe,TRes].Build[T] (System.String s) [0x00001] in <67b134d6092b4965bbed31dc4c300383>:0 
03-01 11:35:32.304 16188 16188 E AndroidRuntime:   at Microsoft.FSharp.Core.PrintfImpl+Cache`4[T,TState,TResidue,TResult].generate (System.String fmt) [0x00006] in <67b134d6092b4965bbed31dc4c300383>:0 
03-01 11:35:32.304 16188 16188 E AndroidRuntime:   at Microsoft.FSharp.Core.PrintfImpl+-cctor@1242-175[T,TState,TResidue,TResult].Invoke (System.String arg) [0x00001] in <67b134d6092b4965bbed31dc4c300383>:0 
03-01 11:35:32.304 16188 16188 E AndroidRuntime:   at System.Collections.Concurrent.ConcurrentDictionary`2[TKey,TValue].GetOrAdd (TKey key, System.Func`2[T,TResult] valueFactory) [0x00037] in <8c304e4006094a46a7950338a3b3cb5d>:0 
03-01 11:35:32.304 16188 16188 E AndroidRuntime:   at Microsoft.FSharp.Core.PrintfImpl+Cache`4[T,TState,TResidue,TResult].get (System.String key) [0x00001] in <67b134d6092b4965bbed31dc4c300383>:0 
03-01 11:35:32.304 16188 16188 E AndroidRuntime:   at Microsoft.FSharp.Core.PrintfImpl+Cache`4[T,TState,TResidue,TResult].Get (Microsoft.FSharp.Core.PrintfFormat`4[TPrinter,TState,TResidue,TResult] key) [0x00037] in <67b134d6092b4965bbed31dc4c300383>:0 
03-01 11:35:32.304 16188 16188 E AndroidRuntime:   at Microsoft.FSharp.Core.PrintfModule.PrintFormatToStringThen[TResult,T] (Microsoft.FSharp.Core.FSharpFunc`2[T,TResult] continutation, Microsoft.FSharp.Core.PrintfFormat`4[TPrinter,TState,TResidue,TResult] format) [0x00001] in <67b134d6092b4965bbed31dc4c300383>:0 
03-01 11:35:32.304 16188 16188 E AndroidRuntime:   at Microsoft.FSharp.Core.ExtraTopLevelOperators.PrintFormatToString[T] (Microsoft.FSharp.Core.PrintfFormat`4[TPrinter,TState,TResidue,TResult] format) [0x00006] in <67b134d6092b4965bbed31dc4c300383>:0 
03-01 11:35:32.304 16188 16188 E AndroidRuntime:   at <StartupCode$SprintfBug>.$MainActivity+OnCreate@29-4.Invoke (System.EventArgs args) [0x00011] in <58b720a1b374c5fda7450383a120b758>:0 
03-01 11:35:32.304 16188 16188 E AndroidRuntime:   at Microsoft.FSharp.Control.CommonExtensions+SubscribeToObservable@2114[T].System-IObserver`1-OnNext (T value) [0x00001] in <67b134d6092b4965bbed31dc4c300383>:0 
03-01 11:35:32.304 16188 16188 E AndroidRuntime:   at Microsoft.FSharp.Core.CompilerServices.RuntimeHelpers+h@788[TArgs].Invoke (System.Object _arg1, TArgs args) [0x00001] in <67b134d6092b4965bbed31dc4c300383>:0 
03-01 11:35:32.304 16188 16188 E AndroidRuntime:   at Microsoft.FSharp.Core.FSharpFunc`2[T,TResult].InvokeFast[V] (Microsoft.FSharp.Core.FSharpFunc`2[T,TResult] func, T arg1, TResult arg2) [0x0000d] in <67b134d6092b4965bbed31dc4c300383>:0 
03-01 11:35:32.304 16188 16188 E AndroidRuntime:   at <StartupCode$SprintfBug>.$MainActivity+OnCreate@29-3.Invoke (System.Object sender, System.EventArgs e) [0x00001] in <58b720a1b374c5fda7450383a120b758>:0 
03-01 11:35:32.304 16188 16188 E AndroidRuntime:   at Android.Views.View+IOnClickListenerImplementor.OnClick (Android.Views.View v) [0x00014] in <e6d6485e1c4241b0bb0cf07f61bb8a53>:0 
03-01 11:35:32.304 16188 16188 E AndroidRuntime:   at Android.Views.View+IOnClickListenerInvoker.n_OnClick_Landroid_view_View_ (System.IntPtr jnienv, System.IntPtr native__this, System.IntPtr native_v) [0x00011] in <e6d6485e1c4241b0bb0cf07f61bb8a53>:0 
03-01 11:35:32.304 16188 16188 E AndroidRuntime:   at (wrapper dynamic-method) System.Object:7e38e2e7-828e-4454-b7f2-7c6c9e5d64f6 (intptr,intptr,intptr)
03-01 11:35:32.304 16188 16188 E AndroidRuntime: 	at mono.android.view.View_OnClickListenerImplementor.n_onClick(Native Method)
03-01 11:35:32.304 16188 16188 E AndroidRuntime: 	at mono.android.view.View_OnClickListenerImplementor.onClick(View_OnClickListenerImplementor.java:30)
03-01 11:35:32.304 16188 16188 E AndroidRuntime: 	at android.view.View.performClick(View.java:5609)
03-01 11:35:32.305 16188 16188 E AndroidRuntime: 	at android.view.View$PerformClick.run(View.java:22262)
03-01 11:35:32.305 16188 16188 E AndroidRuntime: 	at android.os.Handler.handleCallback(Handler.java:751)
03-01 11:35:32.305 16188 16188 E AndroidRuntime: 	at android.os.Handler.dispatchMessage(Handler.java:95)
03-01 11:35:32.305 16188 16188 E AndroidRuntime: 	at android.os.Looper.loop(Looper.java:154)
03-01 11:35:32.305 16188 16188 E AndroidRuntime: 	at android.app.ActivityThread.main(ActivityThread.java:6077)
03-01 11:35:32.305 16188 16188 E AndroidRuntime: 	... 3 more
03-01 11:35:32.307   848  4243 W ActivityManager:   Force finishing activity com.example.sprintfbug/md5d9380e9a4cfabe2f5b4340b04ee09bb7.MainActivity
Comment 1 James Moore 2017-03-01 19:46:43 UTC
=== Visual Studio for Mac Preview ===

Version Preview 3 (7.0 build 1077)
Installation UUID: 54529aae-a4b8-4338-92ef-3daa15673f67
Runtime:
	Mono 4.8.0 (mono-4.8.0-branch/ba7f169) (64-bit)
	GTK+ 2.24.23 (Raleigh theme)

	Package version: 408000483

=== NuGet ===

Version: 4.0.0.2098

=== Xamarin.Profiler ===

Version: 1.1.8
Location: /Applications/Xamarin Profiler.app/Contents/MacOS/Xamarin Profiler

=== Xamarin.Android ===

Version: 7.1.0.34 (Visual Studio Enterprise)
Android SDK: /Users/james/Library/Developer/Xamarin/android-sdk-mac_x86
	Supported Android versions:
		4.4 (API level 19)
		5.0 (API level 21)
		6.0 (API level 23)
		7.0 (API level 24)
		7.1 (API level 25)

SDK Tools Version: 25.2.5
SDK Platform Tools Version: 25.0.3
SDK Build Tools Version: 25.0.2

Java SDK: /Library/Java/JavaVirtualMachines/jdk1.8.0_77.jdk/Contents/Home
java version "1.8.0_77"
Java(TM) SE Runtime Environment (build 1.8.0_77-b03)
Java HotSpot(TM) 64-Bit Server VM (build 25.77-b03, mixed mode)

Android Designer EPL code available here:
https://github.com/xamarin/AndroidDesigner.EPL

=== Apple Developer Tools ===

Xcode 8.2.1 (11766.1)
Build 8C1002

=== Xamarin.iOS ===

Version: 10.4.0.114 (Visual Studio Enterprise)
Hash: 22d559f
Branch: cycle9
Build date: 2017-02-03 16:04:59-0500

=== Xamarin.Mac ===

Version: 3.0.0.384 (Visual Studio Enterprise)

=== Build Information ===

Release ID: 700001077
Git revision: 1b72513a45820d8e9f4c5aef9d3af2021bf48b42
Build date: 2017-01-20 03:53:09-05
Xamarin addins: e96113f03e6238f2ae3267fc754b29307ea9c8e9
Build lane: monodevelop-vNext-preview

=== Operating System ===

Mac OS X 10.12.3
Darwin retina.local 16.4.0 Darwin Kernel Version 16.4.0
    Thu Dec 22 22:53:21 PST 2016
    root:xnu-3789.41.3~3/RELEASE_X86_64 x86_64
Comment 2 James Moore 2017-03-01 20:54:41 UTC
And FYI, this is causing us a real-life problem; we can't use the linker for our app right now.
Comment 4 Jon Goldberger [MSFT] 2017-03-06 21:55:24 UTC
## Bookkeeping note

I will prepare a non-engineering team preliminary quick review for this report.

Template response with reminder notes about common answers 
==========================================================

Non-engineering team preliminary quick review


## Suspected to be a regression or a problem with a new feature?
No, not a regression between Cycle 8 and Cycle 9




## Specific to one particular project, development computer, or target mobile device?
No, I could reproduce this on two Mac machines, one running Cycle 9 and one running Cycle 8. Also, though reported against Visual Studio for Mac, I reproduced on Xamarin Studio (C8 and C9). 



## Describes two closely related scenarios in the same environment that have different behaviors?
No.



## Otherwise, likely corresponds to an incorrect behavior in Xamarin or Mono (rather than a usage question, feature request, or enhancement)?
No, I think this is an issue of using Link All, which generally requires doing some type preserving. 




## Includes clear steps to reproduce the problem?
Yes. I was able to reproduce the issue with a template project as described in the bug description. I was also able to work around the issue by ignoring linking on FSharp.Core, so using "Link All" option is stripping outy "unused code" in FSharp.Core. This issue seems expected due to the linker using static analysis and thus stripping out anything from all assemblies that is not used directly in code. 




## Considers the relevant log files for the part(s) of the process where something goes wrong (IDE editing, MSBuild building, deploying, launching, attaching the debugger, an in-app error, or something else), and has them attached?
Yes. 



## Already took up time for many users?
Unclear. So far this is the only report I have seen of this issue and the bug reporter is the only non-Xamarin in the cc list. 




## Makes development (a) difficult, impossible, or potentially hazardous, (b) moderately inconvenient, or (c) mildly inconvenient for users?
c, but as noted, I think this is expected behavior when using the Link All option. 
See guide on Linker page for details: https://developer.xamarin.com/guides/android/advanced_topics/linking/