31

I am using xamarin forms... And sometimes when I try to go back to my previous page I see this (Android device):

System.NotSupportedException: Unable to activate instance of type Xamarin.Forms.Platform.Android.Platform+DefaultRenderer from native handle 0xbeb4a30c

I saw this same issue with label renderer and box renderer but I solved it by creating a constructor in a custom renderer as the link below suggests:

MonoDroid: Error when calling constructor of custom view - TwoDScrollView

But there's nothing about DefaultRenderer error as all where I have searched in for these last 30 days...I am getting crazy...

complete exception:

System.NotSupportedException: Unable to activate instance of type Xamarin.Forms.Platform.Android.Platform+DefaultRenderer from native handle 0xbecdf3ac (key_handle 0x24da7695).

04-04 11:51:53.914 D/Mono    (30832): DllImport attempting to load: '/system/lib/liblog.so'. 04-04 11:51:53.914 D/Mono    (30832): DllImport loaded library '/system/lib/liblog.so'. 04-04 11:51:53.914 D/Mono    (30832): DllImport searching in: '/system/lib/liblog.so' ('/system/lib/liblog.so'). 04-04 11:51:53.914 D/Mono    (30832): Searching for '__android_log_print'. 04-04 11:51:53.914 D/Mono    (30832): Probing '__android_log_print'. 04-04 11:51:53.914 D/Mono    (30832): Found as '__android_log_print'. 04-04 11:51:53.924 I/MonoDroid(30832): UNHANDLED EXCEPTION: 04-04 11:51:53.944 I/MonoDroid(30832): System.NotSupportedException: Unable to activate instance of type Xamarin.Forms.Platform.Android.Platform+DefaultRenderer from native handle 0xbecdf3ac (key_handle 0x24da7695). ---> System.MissingMethodException: No constructor found for Xamarin.Forms.Platform.Android.Platform+DefaultRenderer::.ctor(System.IntPtr, Android.Runtime.JniHandleOwnership) ---> Java.Interop.JavaLocationException: Exception of type 'Java.Interop.JavaLocationException' was thrown. 04-04 11:51:53.944 I/MonoDroid(30832):    --- End of inner exception stack trace --- 04-04 11:51:53.944 I/MonoDroid(30832):   at Java.Interop.TypeManager.CreateProxy (System.Type type, System.IntPtr handle, Android.Runtime.JniHandleOwnership transfer) [0x00054] in <e79c73bcbbb547688bef6c7e9665c95e>:0  04-04 11:51:53.944 I/MonoDroid(30832):   at Java.Interop.TypeManager.CreateInstance (System.IntPtr handle, Android.Runtime.JniHandleOwnership transfer, System.Type targetType) [0x00111] in <e79c73bcbbb547688bef6c7e9665c95e>:0  04-04 11:51:53.944 I/MonoDroid(30832):    --- End of inner exception stack trace --- 04-04 11:51:53.944 I/MonoDroid(30832):   at Java.Interop.TypeManager.CreateInstance (System.IntPtr handle, Android.Runtime.JniHandleOwnership transfer, System.Type targetType) [0x0017d] in <e79c73bcbbb547688bef6c7e9665c95e>:0  04-04 11:51:53.944 I/MonoDroid(30832):   at Java.Lang.Object.GetObject (System.IntPtr handle, Android.Runtime.JniHandleOwnership transfer, System.Type type) [0x000b9] in <e79c73bcbbb547688bef6c7e9665c95e>:0  04-04 11:51:53.944 I/MonoDroid(30832):   at Java.Lang.Object._GetObject[T] (System.IntPtr handle, Android.Runtime.JniHandleOwnership transfer) [0x00017] in <e79c73bcbbb547688bef6c7e9665c95e>:0  04-04 11:51:53.944 I/MonoDroid(30832):   at Java.Lang.Object.GetObject[T] (System.IntPtr handle, Android.Runtime.JniHandleOwnership transfer) [0x00000] in <e79c73bcbbb547688bef6c7e9665c95e>:0  04-04 11:51:53.944 I/MonoDroid(30832):   at Java.Lang.Object.GetObject[T] (System.IntPtr jnienv, System.IntPtr handle, Android.Runtime.JniHandleOwnership transfer) [0x00006] in <e79c73bcbbb547688bef6c7e9665c95e>:0  04-04 11:51:53.944 I/MonoDroid(30832):   at Android.Views.View.n_DispatchTouchEvent_Landroid_view_MotionEvent_ (System.IntPtr jnienv, System.IntPtr native__this, System.IntPtr native_e) [0x00000] in <e79c73bcbbb547688bef6c7e9665c95e>:0  04-04 11:51:53.944 I/MonoDroid(30832):   at (wrapper dynamic-method) System.Object:cce836e4-e6e4-4d51-a0da-36412953d80b (intptr,intptr,intptr) 04-04 11:51:53.964 W/art     (30832): JNI RegisterNativeMethods: attempt to register 0 native methods for android.runtime.JavaProxyThrowable 04-04 11:51:53.964 D/Mono    (30832): DllImport searching in: '__Internal' ('(null)'). 04-04 11:51:53.964 D/Mono    (30832): Searching for 'java_interop_jnienv_throw'. 04-04 11:51:53.964 D/Mono    (30832): Probing 'java_interop_jnienv_throw'. 04-04 11:51:53.964 D/Mono    (30832): Found as 'java_interop_jnienv_throw'. Unhandled Exception:

System.NotSupportedException: Unable to activate instance of type Xamarin.Forms.Platform.Android.Platform+DefaultRenderer from native handle 0xbecdf3ac (key_handle 0x24da7695).

04-04 11:51:57.014 I/art     (30832): Thread[2,tid=30839,WaitingInMainSignalCatcherLoop,Thread*=0xaf90e400,peer=0x12c4d080,"Signal Catcher"]: reacting to signal 3 04-04 11:51:57.584 I/art     (30832): Wrote stack traces to '/data/anr/traces.txt' 04-04 11:52:07.844 I/MonoDroid(30832): UNHANDLED EXCEPTION: 04-04 11:52:07.894 I/MonoDroid(30832): System.NotSupportedException: Unable to activate instance of type Xamarin.Forms.Platform.Android.Platform+DefaultRenderer from native handle 0xbecdf3ac (key_handle 0x24da7695). ---> System.MissingMethodException: No constructor found for Xamarin.Forms.Platform.Android.Platform+DefaultRenderer::.ctor(System.IntPtr, Android.Runtime.JniHandleOwnership) ---> Java.Interop.JavaLocationException: Exception of type 'Java.Interop.JavaLocationException' was thrown. 04-04 11:52:07.894 I/MonoDroid(30832):    --- End of inner exception stack trace --- 04-04 11:52:07.894 I/MonoDroid(30832):   at Java.Interop.TypeManager.CreateProxy (System.Type type, System.IntPtr handle, Android.Runtime.JniHandleOwnership transfer) [0x00054] in <e79c73bcbbb547688bef6c7e9665c95e>:0  04-04 11:52:07.894 I/MonoDroid(30832):   at Java.Interop.TypeManager.CreateInstance (System.IntPtr handle, Android.Runtime.JniHandleOwnership transfer, System.Type targetType) [0x00111] in <e79c73bcbbb547688bef6c7e9665c95e>:0  04-04 11:52:07.894 I/MonoDroid(30832):    --- End of inner exception stack trace --- 04-04 11:52:07.894 I/MonoDroid(30832):   at (wrapper dynamic-method) System.Object:cce836e4-e6e4-4d51-a0da-36412953d80b (intptr,intptr,intptr) 04-04 11:52:07.894 I/MonoDroid(30832):   at (wrapper managed-to-native) Java.Interop.NativeMethods:java_interop_jnienv_call_nonvirtual_void_method_a (intptr,intptr&,intptr,intptr,intptr,Java.Interop.JniArgumentValue*) 04-04 11:52:07.894 I/MonoDroid(30832):   at Java.Interop.JniEnvironment+InstanceMethods.CallNonvirtualVoidMethod (Java.Interop.JniObjectReference instance, Java.Interop.JniObjectReference type, Java.Interop.JniMethodInfo method, Java.Interop.JniArgumentValue* args) [0x00073] in <e8c0e16a54534fa885244f0ad837c79e>:0  04-04 11:52:07.894 I/MonoDroid(30832):   at Java.Interop.JniPeerMembers+JniInstanceMethods.InvokeVirtualVoidMethod (System.String encodedMember, Java.Interop.IJavaPeerable self, Java.Interop.JniArgumentValue* parameters) [0x0005d] in <e8c0e16a54534fa885244f0ad837c79e>:0  04-04 11:52:07.894 I/MonoDroid(30832):   at Android.Views.ViewGroup.RemoveAllViews () [0x0000a] in <e79c73bcbbb547688bef6c7e9665c95e>:0  04-04 11:52:07.894 I/MonoDroid(30832):   at Xamarin.Forms.Platform.Android.VisualElementRenderer`1[TElement].Dispose (System.Boolean disposing) [0x00088] in D:\agent_work\1\s\Xamarin.Forms.Platform.Android\VisualElementRenderer.cs:238 04-04 11:52:07.894 I/MonoDroid(30832):   at Java.Lang.Object.Dispose () [0x00000] in <e79c73bcbbb547688bef6c7e9665c95e>:0  04-04 11:52:07.894 I/MonoDroid(30832):   at Xamarin.Forms.Platform.Android.ListViewRenderer.ClearRenderer (Android.Views.View renderedView) [0x00032] in D:\agent_work\1\s\Xamarin.Forms.Platform.Android\Renderers\ListViewRenderer.cs:295 04-04 11:52:07.894 I/MonoDroid(30832):   at Xamarin.Forms.Platform.Android.ListViewRenderer.Dispose (System.Boolean disposing) [0x0001e] in D:\agent_work\1\s\Xamarin.Forms.Platform.Android\Renderers\ListViewRenderer.cs:59 04-04 11:52:07.894 I/MonoDroid(30832):   at Java.Lang.Object.Dispose () [0x00000] in <e79c73bcbbb547688bef6c7e9665c95e>:0  04-04 11:52:07.894 I/MonoDroid(30832):   at Xamarin.Forms.Platform.Android.VisualElementRenderer`1[TElement].Dispose (System.Boolean disposing) [0x0007b] in D:\agent_work\1\s\Xamarin.Forms.Platform.Android\VisualElementRenderer.cs:234 04-04 11:52:07.894 I/MonoDroid(30832):   at Java.Lang.Object.Dispose () [0x00000] in <e79c73bcbbb547688bef6c7e9665c95e>:0  04-04 11:52:07.894 I/MonoDroid(30832):   at Xamarin.Forms.Platform.Android.VisualElementRenderer`1[TElement].Dispose (System.Boolean disposing) [0x0007b] in D:\agent_work\1\s\Xamarin.Forms.Platform.Android\VisualElementRenderer.cs:234 04-04 11:52:07.894 I/MonoDroid(30832):   at Xamarin.Forms.Platform.Android.PageRenderer.Dispose (System.Boolean disposing) [0x00011] in D:\agent_work\1\s\Xamarin.Forms.Platform.Android\Renderers\PageRenderer.cs:33 04-04 11:52:07.894 I/MonoDroid(30832):   at Java.Lang.Object.Dispose () [0x00000] in <e79c73bcbbb547688bef6c7e9665c95e>:0  04-04 11:52:07.894 I/MonoDroid(30832):   at Xamarin.Forms.Platform.Android.AppCompat.FragmentContainer.OnDestroyView () [0x0003c] in D:\agent_work\1\s\Xamarin.Forms.Platform.Android\AppCompat\FragmentContainer.cs:91 04-04 11:52:07.894 I/MonoDroid(30832):   at Android.Support.V4.App.Fragment.n_OnDestroyView (System.IntPtr jnienv, System.IntPtr native__this) [0x00008] in <1e89c43d3c7d48b5ba69bfc0b1bdf114>:0  04-04 11:52:07.894 I/MonoDroid(30832):   at (wrapper dynamic-method) System.Object:1df32498-cacf-4686-8c6a-cd4a5d878faf (intptr,intptr) 04-04 11:52:07.914 E/mono-rt (30832): Stacktrace: 04-04 11:52:07.914 E/mono-rt (30832):  04-04 11:52:07.914 E/mono-rt (30832):   at <unknown> <0xffffffff> 04-04 11:52:07.914 E/mono-rt (30832):   at (wrapper managed-to-native) Java.Interop.NativeMethods.java_interop_jnienv_new_string (intptr,intptr&,char*,int) <0x00043> 04-04 11:52:07.914 E/mono-rt (30832):   at Java.Interop.JniEnvironment/Strings.NewString (char*,int) [0x00009] in <e8c0e16a54534fa885244f0ad837c79e>:0 04-04 11:52:07.924 E/mono-rt (30832):   at Java.Interop.JniEnvironment/Strings.NewString (string) [0x00024] in <e8c0e16a54534fa885244f0ad837c79e>:0 04-04 11:52:07.924 E/mono-rt (30832):   at Android.Runtime.JNIEnv.NewString (string) [0x0000a] in <e79c73bcbbb547688bef6c7e9665c95e>:0 04-04 11:52:07.924 E/mono-rt (30832):   at Java.Lang.Error..ctor (string) [0x00020] in <e79c73bcbbb547688bef6c7e9665c95e>:0 04-04 11:52:07.924 E/mono-rt (30832):   at Android.Runtime.JavaProxyThrowable..ctor (System.Exception) [0x00007] in <e79c73bcbbb547688bef6c7e9665c95e>:0 04-04 11:52:07.924 E/mono-rt (30832):   at Java.Lang.Throwable.FromException (System.Exception) [0x0001e] in <e79c73bcbbb547688bef6c7e9665c95e>:0 04-04 11:52:07.924 E/mono-rt (30832):   at Android.Runtime.AndroidEnvironment.UnhandledException (System.Exception) [0x00068] in <e79c73bcbbb547688bef6c7e9665c95e>:0 04-04 11:52:07.924 E/mono-rt (30832):   at (wrapper dynamic-method) object.1df32498-cacf-4686-8c6a-cd4a5d878faf (intptr,intptr) [0x00029] in <657aa8fea4454dc898a9e5f379c58734>:0 04-04 11:52:07.924 E/mono-rt (30832):   at (wrapper native-to-managed) object.1df32498-cacf-4686-8c6a-cd4a5d878faf (intptr,intptr) [0x00021] in <657aa8fea4454dc898a9e5f379c58734>:0 04-04 11:52:07.924 E/mono-rt (30832): /proc/self/maps:
4
  • Do you use some kind of animation for views or page transitions when navigating back? I've faced some troubles with view's animations when throwing it too fast. I solved it calling Task.Yield() before performing the animation itself. Apr 3, 2018 at 12:29
  • I am using the default navigation of xamarin... Apr 3, 2018 at 14:24
  • I am also getting same issue intermittently. I am surprised that nobody answered this question anywhere. May 2, 2018 at 9:14
  • please share mvce
    – Morse
    Oct 12, 2019 at 14:54

1 Answer 1

0

This should be solved by using old JNI constructors and legacy renderers

public MyLabelRenderer(IntPtr handle, JniHandleOwnership transfer)
{
}

and by setting UseLegacyRenderers flag in MainActivity

Forms.SetFlags("UseLegacyRenderers");

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.