Bug 40258 - [Android] System.NotSupportedException Unable to activate instance of type Xamarin.Forms.Platform.Android... from native handle
Summary: [Android] System.NotSupportedException Unable to activate instance of type Xa...
Status: RESOLVED NORESPONSE
Alias: None
Product: Forms
Classification: Xamarin
Component: Android (show other bugs)
Version: 2.2.0
Hardware: PC Windows
: Normal normal
Target Milestone: ---
Assignee: Samantha Houts [MSFT]
URL:
Depends on:
Blocks:
 
Reported: 2016-04-09 21:28 UTC by Mitchell Kutchuk
Modified: 2017-12-06 14:22 UTC (History)
18 users (show)

See Also:
Tags: ac
Is this bug a regression?: ---
Last known good build:


Attachments
Minimal project to reproduce bug. (76.54 KB, application/x-zip-compressed)
2016-10-07 00:16 UTC, Nika Burimenko
Details

Description Mitchell Kutchuk 2016-04-09 21:28:30 UTC
Crashing randomly occurs on Android with "System.NotSupportedException Unable to activate instance of type Xamarin.Forms.Platform.Android... from native handle"

Using Xamarin.Forms 2.2.0.5-pre2

Stacktrace 1:
System.NotSupportedExceptionUnable to activate instance of type Xamarin.Forms.Platform.Android.ListViewRenderer from native handle 0xbecef95c (key_handle 0x282941b8).
Raw
  at Java.Interop.TypeManager.CreateInstance (IntPtr handle, JniHandleOwnership transfer, System.Type targetType) <0xb30e1210 + 0x00648> in <filename unknown>:0 
  at Java.Lang.Object.GetObject (IntPtr handle, JniHandleOwnership transfer, System.Type type) <0xb30e0960 + 0x00387> in <filename unknown>:0 
  at Java.Lang.Object._GetObject[T] (IntPtr handle, JniHandleOwnership transfer) <0xb30e07e0 + 0x0004f> in <filename unknown>:0 
  at Java.Lang.Object.GetObject[T] (IntPtr handle, JniHandleOwnership transfer) <0xb30e05a0 + 0x0002b> in <filename unknown>:0 
  at Java.Lang.Object.GetObject[T] (IntPtr jnienv, IntPtr handle, JniHandleOwnership transfer) <0xaeccc678 + 0x00037> in <filename unknown>:0 
  at Xamarin.Forms.Platform.Android.FormsViewGroup.n_OnLayout_ZIIII (IntPtr jnienv, IntPtr native__this, Boolean p0, Int32 p1, Int32 p2, Int32 p3, Int32 p4) <0xae4119e8 + 0x00053> in <filename unknown>:0 
  at (wrapper dynamic-method) System.Object:1a6441b8-c6cb-4344-95da-fac08bcb9517 (intptr,intptr,bool,int,int,int,int)
System.MissingMethodExceptionNo constructor found for Xamarin.Forms.Platform.Android.ListViewRenderer::.ctor(System.IntPtr, Android.Runtime.JniHandleOwnership)
  at Java.Interop.TypeManager.CreateProxy (System.Type type, IntPtr handle, JniHandleOwnership transfer) <0xb30ea998 + 0x00200> in <filename unknown>:0 
  at Java.Interop.TypeManager.CreateInstance (IntPtr handle, JniHandleOwnership transfer, System.Type targetType) <0xb30e1210 + 0x0034b> in <filename unknown>:0 
Java.Lang.ErrorException of type 'Java.Interop.JavaLocationException' was thrown.
Java.Lang.Error: Exception of type 'Java.Lang.Error' was thrown.

  --- End of managed exception stack trace ---
java.lang.Error: Java callstack:
	at md5b60ffeb829f638581ab2bb9b1a7f4f3f.ListViewRenderer.n_onLayout(Native Method)
	at md5b60ffeb829f638581ab2bb9b1a7f4f3f.ListViewRenderer.onLayout(ListViewRenderer.java:65)
	at android.view.View.layout(View.java:16918)
	at android.view.ViewGroup.layout(ViewGroup.java:5409)
	at com.xamarin.forms.platform.android.FormsViewGroup.measureAndLayout(FormsViewGroup.java:29)
	at md5b60ffeb829f638581ab2bb9b1a7f4f3f.VisualElementRenderer_1.n_onLayout(Native Method)
	at md5b60ffeb829f638581ab2bb9b1a7f4f3f.VisualElementRenderer_1.onLayout(VisualElementRenderer_1.java:49)
	at android.view.View.layout(View.java:16918)
	at android.view.ViewGroup.layout(ViewGroup.java:5409)
	at com.xamarin.forms.platform.android.FormsViewGroup.measureAndLayout(FormsViewGroup.java:29)
	at md5270abb39e60627f0f200893b490a1ade.NavigationPageRenderer.n_onLayout(Native Method)
	at md5270abb39e60627f0f200893b490a1ade.NavigationPageRenderer.onLayout(NavigationPageRenderer.java:63)
	at android.view.View.layout(View.java:16918)
	at android.view.ViewGroup.layout(ViewGroup.java:5409)
	at com.xamarin.forms.platform.android.FormsViewGroup.measureAndLayout(FormsViewGroup.java:29)
	at md5b60ffeb829f638581ab2bb9b1a7f4f3f.MasterDetailContainer.n_onLayout(Native Method)
	at md5b60ffeb829f638581ab2bb9b1a7f4f3f.MasterDetailContainer.onLayout(MasterDetailContainer.java:54)
	at android.view.View.layout(View.java:16918)
	at android.view.ViewGroup.layout(ViewGroup.java:5409)
	at android.support.v4.widget.DrawerLayout.onLayout(DrawerLayout.java:1043)
	at md5270abb39e60627f0f200893b490a1ade.MasterDetailPageRenderer.n_onLayout(Native Method)
	at md5270abb39e60627f0f200893b490a1ade.MasterDetailPageRenderer.onLayout(MasterDetailPageRenderer.java:68)
	at android.view.View.layout(View.java:16918)
	at android.view.ViewGroup.layout(ViewGroup.java:5409)
	at md5b60ffeb829f638581ab2bb9b1a7f4f3f.PlatformRenderer.n_onLayout(Native Method)
	at md5b60ffeb829f638581ab2bb9b1a7f4f3f.PlatformRenderer.onLayout(PlatformRenderer.java:55)
	at android.view.View.layout(View.java:16918)
	at android.view.ViewGroup.layout(ViewGroup.java:5409)
	at android.widget.RelativeLayout.onLayout(RelativeLayout.java:1077)
	at android.view.View.layout(View.java:16918)
	at android.view.ViewGroup.layout(ViewGroup.java:5409)
	at android.widget.FrameLayout.layoutChildren(FrameLayout.java:579)
	at android.widget.FrameLayout.onLayout(FrameLayout.java:514)
	at android.view.View.layout(View.java:16918)
	at android.view.ViewGroup.layout(ViewGroup.java:5409)
	at android.widget.FrameLayout.layoutChildren(FrameLayout.java:579)
	at android.widget.FrameLayout.onLayout(FrameLayout.java:514)
	at android.view.View.layout(View.java:16918)
	at android.view.ViewGroup.layout(ViewGroup.java:5409)
	at android.widget.FrameLayout.layoutChildren(FrameLayout.java:579)
	at android.widget.FrameLayout.onLayout(FrameLayout.java:514)
	at android.view.View.layout(View.java:16918)
	at android.view.ViewGroup.layout(ViewGroup.java:5409)
	at android.widget.LinearLayout.setChildFrame(LinearLayout.java:1702)
	at android.widget.LinearLayout.layoutVertical(LinearLayout.java:1556)
	at android.widget.LinearLayout.onLayout(LinearLayout.java:1465)
	at android.view.View.layout(View.java:16918)
	at android.view.ViewGroup.layout(ViewGroup.java:5409)
	at android.widget.FrameLayout.layoutChildren(FrameLayout.java:579)
	at android.widget.FrameLayout.onLayout(FrameLayout.java:514)
	at android.view.View.layout(View.java:16918)
	at android.view.ViewGroup.layout(ViewGroup.java:5409)
	at android.view.ViewRootImpl.performLayout(ViewRootImpl.java:2434)
	at android.view.ViewRootImpl.performTraversals(ViewRootImpl.java:2137)
	at android.view.ViewRootImpl.doTraversal(ViewRootImpl.java:1277)
	at android.view.ViewRootImpl$TraversalRunnable.run(ViewRootImpl.java:6978)
	at android.view.Choreographer$CallbackRecord.run(Choreographer.java:777)
	at android.view.Choreographer.doCallbacks(Choreographer.java:590)
	at android.view.Choreographer.doFrame(Choreographer.java:560)
	at android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:763)
	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:6873)
	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)

Stacktrace 2:
System.NotSupportedExceptionUnable to activate instance of type Xamarin.Forms.Platform.Android.PageContainer from native handle 0x19 (key_handle 0x13fcb3f6).
Raw
  at Java.Interop.TypeManager.CreateInstance (IntPtr handle, JniHandleOwnership transfer, System.Type targetType) <0xaed19310 + 0x00648> in <filename unknown>:0 
  at Java.Lang.Object.GetObject (IntPtr handle, JniHandleOwnership transfer, System.Type type) <0xaed189f8 + 0x0037f> in <filename unknown>:0 
  at Java.Lang.Object._GetObject[T] (IntPtr handle, JniHandleOwnership transfer) <0xaed18848 + 0x0004f> in <filename unknown>:0 
  at Java.Lang.Object.GetObject[T] (IntPtr handle, JniHandleOwnership transfer) <0xaed185d8 + 0x0002b> in <filename unknown>:0 
  at Android.Views.ViewGroup.GetChildAt (Int32 index) <0x9f0e8c98 + 0x0017f> in <filename unknown>:0 
  at Xamarin.Forms.Platform.Android.AppCompat.NavigationPageRenderer.OnLayout (Boolean changed, Int32 l, Int32 t, Int32 r, Int32 b) <0x9f0e3910 + 0x002bf> in <filename unknown>:0 
  at Xamarin.Forms.Platform.Android.FormsViewGroup.n_OnLayout_ZIIII (IntPtr jnienv, IntPtr native__this, Boolean p0, Int32 p1, Int32 p2, Int32 p3, Int32 p4) <0xae3ff448 + 0x00087> in <filename unknown>:0 
  at (wrapper dynamic-method) System.Object:6126d75d-8a8b-4f0f-a55d-f154bec3dd68 (intptr,intptr,bool,int,int,int,int)
System.MissingMethodExceptionNo constructor found for Xamarin.Forms.Platform.Android.PageContainer::.ctor(System.IntPtr, Android.Runtime.JniHandleOwnership)
  at Java.Interop.TypeManager.CreateProxy (System.Type type, IntPtr handle, JniHandleOwnership transfer) <0xaed230a0 + 0x00200> in <filename unknown>:0 
  at Java.Interop.TypeManager.CreateInstance (IntPtr handle, JniHandleOwnership transfer, System.Type targetType) <0xaed19310 + 0x0034b> in <filename unknown>:0 
Java.Lang.ErrorException of type 'Java.Interop.JavaLocationException' was thrown.
Java.Lang.Error: Exception of type 'Java.Lang.Error' was thrown.

  --- End of managed exception stack trace ---
java.lang.Error: Java callstack:
	at md5270abb39e60627f0f200893b490a1ade.NavigationPageRenderer.n_onLayout(Native Method)
	at md5270abb39e60627f0f200893b490a1ade.NavigationPageRenderer.onLayout(NavigationPageRenderer.java:63)
	at android.view.View.layout(View.java:16918)
	at android.view.ViewGroup.layout(ViewGroup.java:5409)
	at com.xamarin.forms.platform.android.FormsViewGroup.measureAndLayout(FormsViewGroup.java:29)
	at md5b60ffeb829f638581ab2bb9b1a7f4f3f.MasterDetailContainer.n_onLayout(Native Method)
	at md5b60ffeb829f638581ab2bb9b1a7f4f3f.MasterDetailContainer.onLayout(MasterDetailContainer.java:54)
	at android.view.View.layout(View.java:16918)
	at android.view.ViewGroup.layout(ViewGroup.java:5409)
	at android.support.v4.widget.DrawerLayout.onLayout(DrawerLayout.java:1043)
	at md5270abb39e60627f0f200893b490a1ade.MasterDetailPageRenderer.n_onLayout(Native Method)
	at md5270abb39e60627f0f200893b490a1ade.MasterDetailPageRenderer.onLayout(MasterDetailPageRenderer.java:68)
	at android.view.View.layout(View.java:16918)
	at android.view.ViewGroup.layout(ViewGroup.java:5409)
	at md5b60ffeb829f638581ab2bb9b1a7f4f3f.PlatformRenderer.n_onLayout(Native Method)
	at md5b60ffeb829f638581ab2bb9b1a7f4f3f.PlatformRenderer.onLayout(PlatformRenderer.java:55)
	at android.view.View.layout(View.java:16918)
	at android.view.ViewGroup.layout(ViewGroup.java:5409)
	at android.widget.RelativeLayout.onLayout(RelativeLayout.java:1077)
	at android.view.View.layout(View.java:16918)
	at android.view.ViewGroup.layout(ViewGroup.java:5409)
	at android.widget.FrameLayout.layoutChildren(FrameLayout.java:579)
	at android.widget.FrameLayout.onLayout(FrameLayout.java:514)
	at android.view.View.layout(View.java:16918)
	at android.view.ViewGroup.layout(ViewGroup.java:5409)
	at android.widget.FrameLayout.layoutChildren(FrameLayout.java:579)
	at android.widget.FrameLayout.onLayout(FrameLayout.java:514)
	at android.view.View.layout(View.java:16918)
	at android.view.ViewGroup.layout(ViewGroup.java:5409)
	at android.widget.FrameLayout.layoutChildren(FrameLayout.java:579)
	at android.widget.FrameLayout.onLayout(FrameLayout.java:514)
	at android.view.View.layout(View.java:16918)
	at android.view.ViewGroup.layout(ViewGroup.java:5409)
	at android.widget.LinearLayout.setChildFrame(LinearLayout.java:1702)
	at android.widget.LinearLayout.layoutVertical(LinearLayout.java:1556)
	at android.widget.LinearLayout.onLayout(LinearLayout.java:1465)
	at android.view.View.layout(View.java:16918)
	at android.view.ViewGroup.layout(ViewGroup.java:5409)
	at android.widget.FrameLayout.layoutChildren(FrameLayout.java:579)
	at android.widget.FrameLayout.onLayout(FrameLayout.java:514)
	at android.view.View.layout(View.java:16918)
	at android.view.ViewGroup.layout(ViewGroup.java:5409)
	at android.view.ViewRootImpl.performLayout(ViewRootImpl.java:2434)
	at android.view.ViewRootImpl.performTraversals(ViewRootImpl.java:2137)
	at android.view.ViewRootImpl.doTraversal(ViewRootImpl.java:1277)
	at android.view.ViewRootImpl$TraversalRunnable.run(ViewRootImpl.java:6978)
	at android.view.Choreographer$CallbackRecord.run(Choreographer.java:777)
	at android.view.Choreographer.doCallbacks(Choreographer.java:590)
	at android.view.Choreographer.doFrame(Choreographer.java:560)
	at android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:763)
	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:6873)
	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)
Comment 1 adrianknight89 2016-04-12 14:01:45 UTC
I have this problem too. There are/were several related bugs.
Comment 2 Chris King 2016-04-12 22:17:55 UTC
Please attaching a reduced reproduction to the bug. Please start with a clean Xamarin.Forms project and adding just the code necessary to demonstrate the issue. 

Warm regards,
Xamarin Forms Team
Comment 3 adrianknight89 2016-04-26 03:27:19 UTC
I created a repro of a similar issue in another thread. Looks like many people are affected by this problem.

Please see: https://bugzilla.xamarin.com/show_bug.cgi?id=40692
Comment 4 Samantha Houts [MSFT] 2016-06-17 16:41:14 UTC
Do you continue to experience this issue after updating Xamarin.Android?
Comment 5 joshua 2016-09-09 15:06:02 UTC
Yes this bug is still present. I gets error in the simulator by pressing mouse button repeatedly, so that to trigger command before the view is fully shown or something. Nasty bug, expecting fix!!!
Comment 6 Nika Burimenko 2016-10-07 00:16:20 UTC
Created attachment 17918 [details]
Minimal project to reproduce bug.
Comment 7 Nika Burimenko 2016-10-07 00:20:39 UTC
We also suffer from this bug.
I've attach the project to repoduce the bug.
Just quickly switch between pages through Master page.
It's much easier to do on Tablet when Master page is always visible on the screen.
Comment 8 Andrew 2016-10-17 15:08:11 UTC
I am having the same issue.  Here my stack trace.

Xamarin caused by: android.runtime.JavaProxyThrowable: System.NotSupportedException: Unable to activate instance of type Xamarin.Forms.Platform.Android.AppCompat.NavigationPageRenderer from native handle 0xffa8ce0c (key_handle 0x973eefb). ---> System.MissingMethodException: No constructor found for Xamarin.Forms.Platform.Android.AppCompat.NavigationPageRenderer::.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) [0x00058] in <68077cfca7484812b5b64f4af5215b8d>:0 
  at Java.Interop.TypeManager.CreateInstance (System.IntPtr handle, Android.Runtime.JniHandleOwnership transfer, System.Type targetType) [0x00138] in <68077cfca7484812b5b64f4af5215b8d>:0 
   --- End of inner exception stack trace ---
  at Java.Interop.TypeManager.CreateInstance (System.IntPtr handle, Android.Runtime.JniHandleOwnership transfer, System.Type targetType) [0x001b0] in <68077cfca7484812b5b64f4af5215b8d>:0 
  at Java.Lang.Object.GetObject (System.IntPtr handle, Android.Runtime.JniHandleOwnership transfer, System.Type type) [0x000e5] in <68077cfca7484812b5b64f4af5215b8d>:0 
  at Java.Lang.Object._GetObject[T] (System.IntPtr handle, Android.Runtime.JniHandleOwnership transfer) [0x0001a] in <68077cfca7484812b5b64f4af5215b8d>:0 
  at Java.Lang.Object.GetObject[T] (System.IntPtr handle, Android.Runtime.JniHandleOwnership transfer) [0x00000] in <68077cfca7484812b5b64f4af5215b8d>:0 
  at Java.Lang.Object.GetObject[T] (System.IntPtr jnienv, System.IntPtr handle, Android.Runtime.JniHandleOwnership transfer) [0x00006] in <68077cfca7484812b5b64f4af5215b8d>:0 
  at Android.Views.View.n_OnDetachedFromWindow (System.IntPtr jnienv, System.IntPtr native__this) [0x00000] in <68077cfca7484812b5b64f4af5215b8d>:0 
  at (wrapper dynamic-method) System.Object:afcc5a50-dc9a-40ee-8f83-80fcda94e875 (intptr,intptr)
	at md5270abb39e60627f0f200893b490a1ade.NavigationPageRenderer.n_onDetachedFromWindow(Native Method)
	at md5270abb39e60627f0f200893b490a1ade.NavigationPageRenderer.onDetachedFromWindow(NavigationPageRenderer.java:55)
	at android.view.View.dispatchDetachedFromWindow(View.java:14630)
	at android.view.ViewGroup.dispatchDetachedFromWindow(ViewGroup.java:3116)
	at android.view.ViewGroup.dispatchDetachedFromWindow(ViewGroup.java:3108)
	at android.view.ViewGroup.finishAnimatingView(ViewGroup.java:6136)
	at android.view.View.draw(View.java:16196)
	at android.view.ViewGroup.drawChild(ViewGroup.java:3654)
	at android.view.ViewGroup.dispatchDraw(ViewGroup.java:3468)
	at android.view.View.updateDisplayListIfDirty(View.java:15244)
	at android.view.ViewGroup.recreateChildDisplayList(ViewGroup.java:3638)
	at android.view.ViewGroup.dispatchGetDisplayList(ViewGroup.java:3618)
	at android.view.View.updateDisplayListIfDirty(View.java:15209)
	at android.view.ViewGroup.recreateChildDisplayList(ViewGroup.java:3638)
	at android.view.ViewGroup.dispatchGetDisplayList(ViewGroup.java:3618)
	at android.view.View.updateDisplayListIfDirty(View.java:15209)
	at android.view.ViewGroup.recreateChildDisplayList(ViewGroup.java:3638)
	at android.view.ViewGroup.dispatchGetDisplayList(ViewGroup.java:3618)
	at android.view.View.updateDisplayListIfDirty(View.java:15209)
	at android.view.ViewGroup.recreateChildDisplayList(ViewGroup.java:3638)
	at android.view.ViewGroup.dispatchGetDisplayList(ViewGroup.java:3618)
	at android.view.View.updateDisplayListIfDirty(View.java:15209)
	at android.view.ViewGroup.recreateChildDisplayList(ViewGroup.java:3638)
	at android.view.ViewGroup.dispatchGetDisplayList(ViewGroup.java:3618)
	at android.view.View.updateDisplayListIfDirty(View.java:15209)
	at android.view.ViewGroup.recreateChildDisplayList(ViewGroup.java:3638)
	at android.view.ViewGroup.dispatchGetDisplayList(ViewGroup.java:3618)
	at android.view.View.updateDisplayListIfDirty(View.java:15209)
	at android.view.ViewGroup.recreateChildDisplayList(ViewGroup.java:3638)
	at android.view.ViewGroup.dispatchGetDisplayList(ViewGroup.java:3618)
	at android.view.View.updateDisplayListIfDirty(View.java:15209)
	at android.view.ViewGroup.recreateChildDisplayList(ViewGroup.java:3638)
	at android.view.ViewGroup.dispatchGetDisplayList(ViewGroup.java:3618)
	at android.view.View.updateDisplayListIfDirty(View.java:15209)
	at android.view.ThreadedRenderer.updateViewTreeDisplayList(ThreadedRenderer.java:281)
	at android.view.ThreadedRenderer.updateRootDisplayList(ThreadedRenderer.java:287)
	at android.view.ThreadedRenderer.draw(ThreadedRenderer.java:322)
	at android.view.ViewRootImpl.draw(ViewRootImpl.java:2681)
	at android.view.ViewRootImpl.performDraw(ViewRootImpl.java:2495)
	at android.view.ViewRootImpl.performTraversals(ViewRootImpl.java:2124)
	at android.view.ViewRootImpl.doTraversal(ViewRootImpl.java:1140)
	at android.view.ViewRootImpl$TraversalRunnable.run(ViewRootImpl.java:6239)
	at android.view.Choreographer$CallbackRecord.run(Choreographer.java:858)
	at android.view.Choreographer.doCallbacks(Choreographer.java:670)
	at android.view.Choreographer.doFrame(Choreographer.java:606)
	at android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:844)
	at android.os.Handler.handleCallback(Handler.java:739)
	at android.os.Handler.dispatchMessage(Handler.java:95)
	at android.os.Looper.loop(Looper.java:148)
	at android.app.ActivityThread.main(ActivityThread.java:5551)
	at java.lang.reflect.Method.invoke(Native Method)
	at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:730)
	at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:620)
Comment 9 Seifer 2016-11-01 13:36:32 UTC
I do have the same error as Andrew.

System.NotSupportedException: Unable to activate instance of type Xamarin.Forms.Platform.Android.AppCompat.NavigationPageRenderer from native handle 0xffa8ce0c (key_handle 0x973eefb). ---> System.MissingMethodException: No constructor found for Xamarin.Forms.Platform.Android.AppCompat.NavigationPageRenderer::.ctor(System.IntPtr, Android.Runtime.JniHandleOwnership) ---> Java.Interop.JavaLocationException: Exception of type 'Java.Interop.JavaLocationException' was thrown.
Comment 10 hiraldesai 2016-11-02 17:10:50 UTC
Xamarin caused by: android.runtime.JavaProxyThrowable: System.NotSupportedException: Unable to activate instance of type Xamarin.Forms.Platform.Android.AppCompat.NavigationPageRenderer from native handle 0xbfc1c79c (key_handle 0xf221b17). ---> System.MissingMethodException: No constructor found for Xamarin.Forms.Platform.Android.AppCompat.NavigationPageRenderer::.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) [0x00039] in /Users/builder/data/lanes/3819/96c7ba6c/source/xamarin-android/src/Mono.Android/Java.Interop/TypeManager.cs:304 
  at Java.Interop.TypeManager.CreateInstance (System.IntPtr handle, Android.Runtime.JniHandleOwnership transfer, System.Type targetType) [0x00138] in /Users/builder/data/lanes/3819/96c7ba6c/source/xamarin-android/src/Mono.Android/Java.Interop/TypeManager.cs:282 
   --- End of inner exception stack trace ---
  at Java.Interop.TypeManager.CreateInstance (System.IntPtr handle, Android.Runtime.JniHandleOwnership transfer, System.Type targetType) [0x00186] in /Users/builder/data/lanes/3819/96c7ba6c/source/xamarin-android/src/Mono.Android/Java.Interop/TypeManager.cs:289 
  at Java.Lang.Object.GetObject (System.IntPtr handle, Android.Runtime.JniHandleOwnership transfer, System.Type type) [0x000e5] in /Users/builder/data/lanes/3819/96c7ba6c/source/xamarin-android/src/Mono.Android/Java.Lang/Object.cs:459 
  at Java.Lang.Object._GetObject[T] (System.IntPtr handle, Android.Runtime.JniHandleOwnership transfer) [0x0001a] in /Users/builder/data/lanes/3819/96c7ba6c/source/xamarin-android/src/Mono.Android/Java.Lang/Object.cs:430 
  at Java.Lang.Object.GetObject[T] (System.IntPtr handle, Android.Runtime.JniHandleOwnership transfer) [0x00000] in /Users/builder/data/lanes/3819/96c7ba6c/source/xamarin-android/src/Mono.Android/Java.Lang/Object.cs:422 
  at Java.Lang.Object.GetObject[T] (System.IntPtr jnienv, System.IntPtr handle, Android.Runtime.JniHandleOwnership transfer) [0x00006] in /Users/builder/data/lanes/3819/96c7ba6c/source/xamarin-android/src/Mono.Android/Java.Lang/Object.cs:416 
  at Android.Views.View.n_OnDetachedFromWindow (System.IntPtr jnienv, System.IntPtr native__this) [0x00000] in /Users/builder/data/lanes/3819/96c7ba6c/source/monodroid/src/Mono.Android/platforms/android-24/src/generated/Android.Views.View.cs:14342 
  at (wrapper dynamic-method) System.Object:84a3b5fb-fcb6-48bb-a753-ecdba0839d84 (intptr,intptr)
	at md5270abb39e60627f0f200893b490a1ade.NavigationPageRenderer.n_onDetachedFromWindow(Native Method)
	at md5270abb39e60627f0f200893b490a1ade.NavigationPageRenderer.onDetachedFromWindow(NavigationPageRenderer.java:55)
	at android.view.View.dispatchDetachedFromWindow(View.java:15443)
	at android.view.ViewGroup.dispatchDetachedFromWindow(ViewGroup.java:3224)
	at android.view.ViewGroup.dispatchDetachedFromWindow(ViewGroup.java:3216)
	at android.view.ViewGroup.finishAnimatingView(ViewGroup.java:6261)
	at android.view.View.draw(View.java:17012)
	at android.view.ViewGroup.drawChild(ViewGroup.java:3764)
	at android.view.ViewGroup.dispatchDraw(ViewGroup.java:3574)
	at android.view.View.updateDisplayListIfDirty(View.java:16045)
	at android.view.ViewGroup.recreateChildDisplayList(ViewGroup.java:3748)
	at android.view.ViewGroup.dispatchGetDisplayList(ViewGroup.java:3728)
	at android.view.View.updateDisplayListIfDirty(View.java:16013)
	at android.view.ViewGroup.recreateChildDisplayList(ViewGroup.java:3748)
	at android.view.ViewGroup.dispatchGetDisplayList(ViewGroup.java:3728)
	at android.view.View.updateDisplayListIfDirty(View.java:16013)
	at android.view.ViewGroup.recreateChildDisplayList(ViewGroup.java:3748)
	at android.view.ViewGroup.dispatchGetDisplayList(ViewGroup.java:3728)
	at android.view.View.updateDisplayListIfDirty(View.java:16013)
	at android.view.ViewGroup.recreateChildDisplayList(ViewGroup.java:3748)
	at android.view.ViewGroup.dispatchGetDisplayList(ViewGroup.java:3728)
	at android.view.View.updateDisplayListIfDirty(View.java:16013)
	at android.view.ViewGroup.recreateChildDisplayList(ViewGroup.java:3748)
	at android.view.ViewGroup.dispatchGetDisplayList(ViewGroup.java:3728)
	at android.view.View.updateDisplayListIfDirty(View.java:16013)
	at android.view.ViewGroup.recreateChildDisplayList(ViewGroup.java:3748)
	at android.view.ViewGroup.dispatchGetDisplayList(ViewGroup.java:3728)
	at android.view.View.updateDisplayListIfDirty(View.java:16013)
	at android.view.ViewGroup.recreateChildDisplayList(ViewGroup.java:3748)
	at android.view.ViewGroup.dispatchGetDisplayList(ViewGroup.java:3728)
	at android.view.View.updateDisplayListIfDirty(View.java:16013)
	at android.view.ViewGroup.recreateChildDisplayList(ViewGroup.java:3748)
	at android.view.ViewGroup.dispatchGetDisplayList(ViewGroup.java:3728)
	at android.view.View.updateDisplayListIfDirty(View.java:16013)
	at android.view.ThreadedRenderer.updateViewTreeDisplayList(ThreadedRenderer.java:656)
	at android.view.ThreadedRenderer.updateRootDisplayList(ThreadedRenderer.java:662)
	at android.view.ThreadedRenderer.draw(ThreadedRenderer.java:770)
	at android.view.ViewRootImpl.draw(ViewRootImpl.java:2796)
	at android.view.ViewRootImpl.performDraw(ViewRootImpl.java:2604)
	at android.view.ViewRootImpl.performTraversals(ViewRootImpl.java:2211)
	at android.view.ViewRootImpl.doTraversal(ViewRootImpl.java:1246)
	at android.view.ViewRootImpl$TraversalRunnable.run(ViewRootImpl.java:6301)
	at android.view.Choreographer$CallbackRecord.run(Choreographer.java:871)
	at android.view.Choreographer.doCallbacks(Choreographer.java:683)
	at android.view.Choreographer.doFrame(Choreographer.java:619)
	at android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:857)
	at android.os.Handler.handleCallback(Handler.java:751)
	at android.os.Handler.dispatchMessage(Handler.java:95)
	at android.os.Looper.loop(Looper.java:154)
	at android.app.ActivityThread.main(ActivityThread.java:6077)
	at java.lang.reflect.Method.invoke(Native Method)
	at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:865)
	at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:755)
Comment 11 Seifer 2016-11-03 12:55:43 UTC
Here is a fix I'm using in my app https://gist.github.com/SeeD-Seifer/ff8b522f7e8b55ec719f68e1765b0314
Comment 12 hiraldesai 2016-11-05 05:47:45 UTC
Thanks - the fix works for me. I'd just keep this - no need for constructors really.

    public class FixedNavigationRenderer : NavigationPageRenderer
    {        
        protected override void OnDetachedFromWindow()
        {
            if (Element == null)            
                return;
            
            base.OnDetachedFromWindow();
        }
    }
Comment 13 Seifer 2016-11-05 19:06:57 UTC
Hm... but the initial exception is `No constructor found for NavigationPageRenderer(System.IntPtr, Android.Runtime.JniHandleOwnership)`, isn't it?

Does it disappear with only `OnDetachedFromWindow` override?
Comment 14 hiraldesai 2016-11-05 20:01:00 UTC
You're right - apologies for jumping to conclusion.
Comment 15 Matheus Silva 2016-11-28 12:30:08 UTC
Hi everyone, 

I'm having the same problem and have tried all of the solutions, but I need to sort this out. I will explain what is happening: I have a page with a listview and a back button for the home of the app, in that listview I created a menuitem to delete the selected item (the deletion works) but when I touch the button go back to the home page With a selected item (menuitem displayed) the app closes and the following error appears in the log:


System.NotSupportedException: Unable to activate instance of type Xamarin.Forms.Platform.Android.ListViewAdapter from native handle 0x9ed00019 (key_handle 0x21bac78c). 
   ---> System.MissingMethodException: No constructor found for Xamarin.Forms.Platform.Android.ListViewAdapter::.ctor(System.IntPtr, Android.Runtime.JniHandleOwnership) 
   ---> Java.Interop.JavaLocationException: Exception of type 'Java.Interop.JavaLocationException' was thrown.


Full log:

 UNHANDLED EXCEPTION:
 System.NotSupportedException: Unable to activate instance of type Xamarin.Forms.Platform.Android.ListViewAdapter from native handle 0x9ed00019 (key_handle 0x21bac78c). ---> System.MissingMethodException: No constructor found for Xamarin.Forms.Platform.Android.ListViewAdapter::.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) [0x00058] in <df8df2a648bf4b77b8ba9c94cca866ba>:0 
   at Java.Interop.TypeManager.CreateInstance (System.IntPtr handle, Android.Runtime.JniHandleOwnership transfer, System.Type targetType) [0x00138] in <df8df2a648bf4b77b8ba9c94cca866ba>:0 
    --- End of inner exception stack trace ---
   at Java.Interop.TypeManager.CreateInstance (System.IntPtr handle, Android.Runtime.JniHandleOwnership transfer, System.Type targetType) [0x001b0] in <df8df2a648bf4b77b8ba9c94cca866ba>:0 
   at Java.Lang.Object.GetObject (System.IntPtr handle, Android.Runtime.JniHandleOwnership transfer, System.Type type) [0x000e5] in <df8df2a648bf4b77b8ba9c94cca866ba>:0 
   at Java.Lang.Object._GetObject[T] (System.IntPtr handle, Android.Runtime.JniHandleOwnership transfer) [0x0001a] in <df8df2a648bf4b77b8ba9c94cca866ba>:0 
   at Java.Lang.Object.GetObject[T] (System.IntPtr handle, Android.Runtime.JniHandleOwnership transfer) [0x00000] in <df8df2a648bf4b77b8ba9c94cca866ba>:0 
   at Java.Lang.Object.GetObject[T] (System.IntPtr jnienv, System.IntPtr handle, Android.Runtime.JniHandleOwnership transfer) [0x00006] in <df8df2a648bf4b77b8ba9c94cca866ba>:0 
   at Android.Views.ActionMode+ICallbackInvoker.n_OnDestroyActionMode_Landroid_view_ActionMode_ (System.IntPtr jnienv, System.IntPtr native__this, System.IntPtr native_mode) [0x00000] in <df8df2a648bf4b77b8ba9c94cca866ba>:0 
   at (wrapper dynamic-method) System.Object:5fbd05e1-a8bf-472d-993c-d3380f989c91 (intptr,intptr,intptr)

BR,
Matheus Silva
Comment 16 Seifer 2016-11-28 13:36:22 UTC
@Matheus whenever you see this crash, you need to provide overridden class with this new constructor. You have to implement a few descendants in case it's impossible to provide new class by one step.
Comment 17 Matheus Silva 2016-11-28 14:44:18 UTC
Hi @Seifer,

I've created this new constructor, but it's never called. What would be another step you commented about I have to implement a few descendants? I do not understand much, it follows the code of my CustomRenderer:

Constructor:
always called ---> ListViewCustomRenderer()
never called  ---> ListViewCustomRenderer(IntPtr javaReference, JniHandleOwnership transfer)


CODE:
using System;
using Android.Runtime;
using teste.Custom;
using Xamarin.Forms;
using teste.Droid.Controls;

[assembly: ExportRenderer(typeof(ListViewCustom), typeof(ListViewCustomRenderer))]

namespace teste.Droid.Controls
{
    public class ListViewCustomRenderer : Xamarin.Forms.Platform.Android.ListViewRenderer
    {
        public ListViewCustomRenderer()
            : base() { }

        public ListViewCustomRenderer(IntPtr javaReference, JniHandleOwnership transfer)
            : base() { }

        protected override void OnDetachedFromWindow()
        {
            if (Element == null)
                return;

            base.OnDetachedFromWindow();
        }    
   }
}

Thank's!
Comment 18 Ashley Gazich [MSFT] 2017-02-02 20:01:46 UTC
I am unable to produce a crash using the sample from Comment 6 with Xamarin.Forms 2.3.4.184-pre1 on Samsung Galaxy S5 (API 23).

If anyone is still hitting this, please provide:
- An updated minimized runnable sample
- Any additional testing details (device/emulator, API level, approx. # runs to observe crash)
- Full version info https://developer.xamarin.com/guides/cross-platform/troubleshooting/questions/version-logs/


### Xamarin Support version info

Microsoft Visual Studio Professional 2015
Version 14.0.25431.01 Update 3
Microsoft .NET Framework
Version 4.6.01586

Installed Version: Professional

LightSwitch for Visual Studio 2015   00322-50050-30523-AA140
Microsoft LightSwitch for Visual Studio 2015

Visual Basic 2015   00322-50050-30523-AA140
Microsoft Visual Basic 2015

Visual C# 2015   00322-50050-30523-AA140
Microsoft Visual C# 2015

Visual C++ 2015   00322-50050-30523-AA140
Microsoft Visual C++ 2015

Visual F# 2015   00322-50050-30523-AA140
Microsoft Visual F# 2015

Application Insights Tools for Visual Studio Package   7.17.00119.9
Application Insights Tools for Visual Studio

ASP.NET and Web Tools 2015.1 (Beta8)   14.1.11107.0
ASP.NET and Web Tools 2015.1 (Beta8)

ASP.NET Web Frameworks and Tools 2012.2   4.1.41102.0
For additional information, visit http://go.microsoft.com/fwlink/?LinkID=309563

ASP.NET Web Frameworks and Tools 2013   5.2.40314.0
For additional information, visit http://www.asp.net/

Command Bus, Event Stream and Async Manager   Merq
Provides ICommandBus, IEventStream and IAsyncManager MEF services for loosely coupled Visual Studio extension components communication and integration.

Common Azure Tools   1.8
Provides common services for use by Azure Mobile Services and Microsoft Azure Tools.

JavaScript Language Service   2.0
JavaScript Language Service

JavaScript Project System   2.0
JavaScript Project System

Microsoft Azure Mobile Services Tools   1.4
Microsoft Azure Mobile Services Tools

NuGet Package Manager   3.4.4
NuGet Package Manager in Visual Studio. For more information about NuGet, visit http://docs.nuget.org/.

PreEmptive Analytics Visualizer   1.2
Microsoft Visual Studio extension to visualize aggregated summaries from the PreEmptive Analytics product.

SQL Server Data Tools   14.0.60519.0
Microsoft SQL Server Data Tools

TypeScript   1.8.36.0
TypeScript tools for Visual Studio

Xamarin   4.2.2.11 (00fa5cc)
Visual Studio extension to enable development for Xamarin.iOS and Xamarin.Android.

Xamarin.Android   7.0.2.42 (501e63c)
Visual Studio extension to enable development for Xamarin.Android.

Xamarin.iOS   10.3.1.8 (7beaef4)
Visual Studio extension to enable development for Xamarin.iOS.
Comment 19 Suat Korkmaz 2017-04-03 11:31:04 UTC
Just joined the party.

Xamarin.Android is unable to Dispose a ViewRenderer which is in my case XWalkView. I did override the Dispose() and blocked its base to dispose the item but as the renderer can not dispose the control the old instances remain in the memory.
Comment 21 Samantha Houts [MSFT] 2017-05-24 21:52:43 UTC
Resetting status based on new comments.
Comment 22 Samantha Houts [MSFT] 2017-05-25 18:27:37 UTC
As in Comment 18, I can confirm that the error that occurs in the reproduction provided in Comment 6 no longer occurs as of version 2.3.3 stable.

This is, unfortunately, a somewhat common error message that can happen for a variety of reasons, so I cannot rule out that there are additional instances of this issue somewhere else in the code base that may be affecting the other users watching this issue.

For those of you still watching this issue, can you please confirm for me that the issue is still present after updating to XF 2.3.3+ AND updating Xamarin.Android to latest stable? If so, please give me your stack trace with the Linker disabled and any other info you have readily available.

Thank you!
Comment 23 Rui Marinho 2017-06-20 14:23:30 UTC
Because we have not received a reply to our request for more information we are
closing this issue. If you are still encountering this issue, please reopen the
ticket with the requested information. Thanks!
Comment 24 christian.bilodeau 2017-10-02 17:26:09 UTC
Hi!

I have the same issue as Suat Korkmaz above. When I try to dispose of a custom renderer which has the purpose of bringing the tab bar to the bottom in a tab page, I get this. Like Suat says, I can bypass the disposal but that's clearly not ideal. Thanks.

System.NotSupportedException: Unable to activate instance of type Xamarin.Forms.Platform.Android.PageContainer from native handle 0x20001d (key_handle 0x5c20d93). ---> System.MissingMethodException: No constructor found for Xamarin.Forms.Platform.Android.PageContainer::.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 <d278c06ad5684d6882c743a94a93ebc2>:0 
  at Java.Interop.TypeManager.CreateInstance (System.IntPtr handle, Android.Runtime.JniHandleOwnership transfer, System.Type targetType) [0x00111] in <d278c06ad5684d6882c743a94a93ebc2>:0 
   --- End of inner exception stack trace ---
  at Java.Interop.TypeManager.CreateInstance (System.IntPtr handle, Android.Runtime.JniHandleOwnership transfer, System.Type targetType) [0x0017d] in <d278c06ad5684d6882c743a94a93ebc2>:0 
  at Java.Lang.Object.GetObject (System.IntPtr handle, Android.Runtime.JniHandleOwnership transfer, System.Type type) [0x000b9] in <d278c06ad5684d6882c743a94a93ebc2>:0 
  at Java.Lang.Object._GetObject[T] (System.IntPtr handle, Android.Runtime.JniHandleOwnership transfer) [0x00017] in <d278c06ad5684d6882c743a94a93ebc2>:0 
  at Java.Lang.Object.GetObject[T] (System.IntPtr handle, Android.Runtime.JniHandleOwnership transfer) [0x00000] in <d278c06ad5684d6882c743a94a93ebc2>:0 
  at Android.Views.View.get_Parent () [0x0001f] in <d278c06ad5684d6882c743a94a93ebc2>:0 
  at Xamarin.Forms.Platform.Android.ViewExtensions.RemoveFromParent (Android.Views.View view) [0x00004] in C:\BuildAgent3\work\ca3766cfc22354a1\Xamarin.Forms.Platform.Android\ViewExtensions.cs:25 
  at Xamarin.Forms.Platform.Android.AppCompat.FragmentContainer.OnDestroyView () [0x0002c] in C:\BuildAgent3\work\ca3766cfc22354a1\Xamarin.Forms.Platform.Android\AppCompat\FragmentContainer.cs:88 
  at Android.Support.V4.App.Fragment.n_OnDestroyView (System.IntPtr jnienv, System.IntPtr native__this) [0x00009] in <7e083afc7c9045f59e01d9c14931060d>:0 
  at (wrapper dynamic-method) System.Object:52980d9b-003e-4391-8393-4bba4866e61a (intptr,intptr)
Comment 25 Seifer 2017-12-06 14:22:32 UTC
I'm not sure if it's the best ticket to discuss, but this ticket is about (IntPtr handle, JniHandleOwnership transfer) constructors anyway.

So today we've updated Xamarin.Forms to 2.5.0 where Forms.Context is obsolete and so that all constructors should be updated.

All our Android custom renderers apart from default MyRenderer() constructor have MyRenderer(IntPtr handle, JniHandleOwnership transfer) constructor too.

The question is:

- should not every Xamarin.Forms Android renderer has an implementation of (IntPtr handle, JniHandleOwnership transfer) constructor?

It seems they are important, but I have no clue why Xamarin.Forms renderers don't have them. Is there a reason for this? Or it's just a missing part that should be there but the team lack of time to add them?

Note You need to log in before you can comment on or make changes to this bug.