0

I am sometimes getting the following exception:

Unhandled Exception: Android.Runtime.JavaProxyThrowable: Exception of type 'Android.Runtime.JavaProxyThrowable' was thrown.
  --- End of managed Android.Runtime.JavaProxyThrowable stack trace ---
android.runtime.JavaProxyThrowable: System.NotSupportedException: Unable to activate instance of type TaxiTabletUniversal.Droid.Views.SoftMeterView from native handle 0xbe8cfb2c (key_handle 0x369e8281). ---> System.MissingMethodException: No constructor found for TaxiTabletUniversal.Droid.Views.SoftMeterView::.ctor(System.IntPtr, Android.Runtime.JniHandleOwnership) ---> Java.Interop.JavaLocationException: Exception of type 'Java.Interop.JavaLocationException' was thrown.
   --- End of inner exception stack trace ---
  at Java.Interop.TypeManager.CreateProxy (System.Type type, System.IntPtr handle, Android.Runtime.JniHandleOwnership transfer) [0x00054] in <5ade030ddd6b4e4c9dda56516f1de4fe>:0 
  at Java.Interop.TypeManager.CreateInstance (System.IntPtr handle, Android.Runtime.JniHandleOwnership transfer, System.Type targetType) [0x00111] in <5ade030ddd6b4e4c9dda56516f1de4fe>:0 
   --- End of inner exception stack trace ---
  at Java.Interop.TypeManager.CreateInstance (System.IntPtr handle, Android.Runtime.JniHandleOwnership transfer, System.Type targetType) [0x0017d] in <5ade030ddd6b4e4c9dda56516f1de4fe>:0 
  at Java.Lang.Object.GetObject (System.IntPtr handle, Android.Runtime.JniHandleOwnership transfer, System.Type type) [0x000b9] in <5ade030ddd6b4e4c9dda56516f1de4fe>:0 
  at Java.Lang.Object._GetObject[T] (System.IntPtr handle, Android.Runtime.JniHandleOwnership transfer) [0x00017] in <5ade030ddd6b4e4c9dda56516f1de4fe>:0 
  at Java.Lang.Object.GetObject[T] (System.IntPtr handle, Android.Runtime.JniHandleOwnership transfer) [0x00000] in <5ade030ddd6b4e4c9dda56516f1de4fe>:0 
  at Java.Lang.Object.GetObject[T] (System.IntPtr jnienv, System.IntPtr handle, Android.Runtime.JniHandleOwnership transfer) [0x00006] in <5ade030ddd6b4e4c9dda56516f1de4fe>:0 
  at Android.Views.ViewTreeObserver+IOnGlobalLayoutListenerInvoker.n_OnGlobalLayout (System.IntPtr jnienv, System.IntPtr native__this) [0x00000] in <5ade030ddd6b4e4c9dda56516f1de4fe>:0 
  at (wrapper dynamic-method) System.Object.90422e09-526e-4347-b02e-8c2980bde53e(intptr,intptr)
    at mvvmcross.droid.views.MvxActivity.n_onGlobalLayout(Native Method)
    at mvvmcross.droid.views.MvxActivity.onGlobalLayout(MvxActivity.java:84)
    at android.view.ViewTreeObserver.dispatchOnGlobalLayout(ViewTreeObserver.java:986)
    at android.view.ViewRootImpl.performTraversals(ViewRootImpl.java:2221)
    at android.view.ViewRootImpl.doTraversal(ViewRootImpl.java:1306)
    at android.view.ViewRootImpl$TraversalRunnable.run(ViewRootImpl.java:7031)
    at android.view.Choreographer$CallbackRecord.run(Choreographer.java:821)
    at android.view.Choreographer.doCallbacks(Choreographer.java:606)
    at android.view.Choreographer.doFrame(Choreographer.java:576)
    at android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:807)
    at android.os.Handler.handleCallback(Handler.java:739)
    at android.os.Handler.dispatchMessage(Handler.java:95)
    at android.os.Looper.loop(Looper.java:145)
    at android.app.ActivityThread.main(ActivityThread.java:6914)
    at java.lang.reflect.Method.invoke(Native Method)
    at java.lang.reflect.Method.invoke(Method.java:372)
    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1404)
    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1199)

with the bit that stands out from that exception saying :

No constructor found for TaxiTabletUniversal.Droid.Views.SoftMeterView::.ctor(System.IntPtr, Android.Runtime.JniHandleOwnership)

But the class SoftmeterView (derived from MvxActivity) does have 2 constructors:

public SoftMeterView() : base()
{
    MoveTaskToBack(true);
    IsCreated = true;
}

with the second one matching the exact signature the exception is complaining about:

public SoftMeterView(IntPtr javaReference, JniHandleOwnership transfer) : base(javaReference, transfer)
{
    MoveTaskToBack(true);
    IsCreated = true;
}

any thoughts ?

clogwog
  • 343
  • 2
  • 13
  • 1
    Have you tried cleaning the solution + delete obj & bin folder? – Csharpest May 22 '18 at 13:09
  • Yes, i even have a powershell script that does that for me (wouldn't be the first time vs and/or xamarin get confused) – clogwog May 23 '18 at 00:38
  • Hope this [answer](https://stackoverflow.com/a/10603714/7063418) may help. – Billy Liu - MSFT May 30 '18 at 08:29
  • @BillyLiu-MSFT thank you. From what i understand from that article is that you need to supply the constructor with the (IntPtr , JniHandleOwnership) signature.. but i have supplied that constructor.. that is what i do not understand. – clogwog Jun 01 '18 at 01:30

0 Answers0