Bug 40738 - [6.1.0.37] MissingMethodException: No constructor found runtime errors
Summary: [6.1.0.37] MissingMethodException: No constructor found runtime errors
Status: RESOLVED ANSWERED
Alias: None
Product: Android
Classification: Xamarin
Component: Mono runtime / AOT Compiler ()
Version: unspecified
Hardware: PC Windows
: --- normal
Target Milestone: ---
Assignee: Jonathan Pryor
URL:
Depends on:
Blocks:
 
Reported: 2016-04-27 16:43 UTC by softlion
Modified: 2016-04-29 16:23 UTC (History)
1 user (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:
RESOLVED ANSWERED

Description softlion 2016-04-27 16:43:09 UTC
Hi,
i recompiled an Android app using the beta channel.
Sometimes this app throws these exceptions.
It did not happen using the stable channel.

It seems mono tries to create an instance using an existing native handle, and requires a new constructor which is missing from my class "HomeView".

Any clue ?

InnerException was MissingMethodException: No constructor found for Ac.Droid.Views.HomeView::.ctor
04-27 18:29:48.805 18966 18966 E mvx     : (System.IntPtr, Android.Runtime.JniHandleOwnership)
04-27 18:29:48.805 18966 18966 E mvx     :        at Java.Interop.TypeManager.CreateProxy (System.Type type, IntPtr handle, JniHandleOwnership transfer) <0
04-27 18:29:48.805 18966 18966 E mvx     : x9d07cba0 + 0x001c0> in <filename unknown>:0
04-27 18:29:48.805 18966 18966 E mvx     :   at Java.Interop.TypeManager.CreateInstance (IntPtr handle, JniHandleOwnership transfer, System.Type targetType)
04-27 18:29:48.806 18966 18966 E mvx     : <0x9d073bb8 + 0x0030b> in <filename unknown>:0
04-27 18:29:48.806 18966 18966 E mvx     : InnerException was JavaLocationException: Exception of type 'Java.Interop.JavaLocationException' was thrown.
04-27 18:29:48.806 18966 18966 E mvx     :      Ja
04-27 18:29:48.806 18966 18966 E mvx     : va.Lang.Error: Exception of type 'Java.Lang.Error' was thrown.
04-27 18:29:48.806 18966 18966 E mvx     :
04-27 18:29:48.806 18966 18966 E mvx     :   --- End of managed exception stack trace ---
04-27 18:29:48.806 18966 18966 E mvx     : java.lang.Error: Java callstack:
04-27 18:29:48.806 18966 18966 E mvx     :      at md5bb3263515
04-27 18:29:48.806 18966 18966 E mvx     : b86dacc445e032b84f8ab62.MvxEventSourceFragment.n_onAttach(Native Method)
04-27 18:29:48.806 18966 18966 E mvx     :      at md5bb3263515b86dacc445e032b84f8ab62.MvxEventSourceFragment.onAttach(MvxEventSourceF
04-27 18:29:48.806 18966 18966 E mvx     : ragment.java:39)
04-27 18:29:48.806 18966 18966 E mvx     :      at android.app.Fragment.onAttach(Fragment.java:1380)
04-27 18:29:48.806 18966 18966 E mvx     :      at android.app.FragmentManagerImpl.moveToState(FragmentManager.java:932)
Comment 1 Jonathan Pryor 2016-04-29 16:23:36 UTC
Please upgrade to the Cycle 7 Release Candidate, Xamarin.Android 6.1.0.48.

That contains fixes to Mono's WeakReference type, which was causing Java.Lang.Object and other bridged instances to be prematurely collected, which in turn would result in the MissingMethodException error.