Bug 57802 - FastRenderers.LabelRenderer encounters NotSupportedException, MissingMethodException (2.3.5.255-pre5)
Summary: FastRenderers.LabelRenderer encounters NotSupportedException, MissingMethodEx...
Status: RESOLVED NOT_REPRODUCIBLE
Alias: None
Product: Forms
Classification: Xamarin
Component: Android ()
Version: 2.4.0
Hardware: PC Windows
: Normal normal
Target Milestone: ---
Assignee: Bugzilla
URL:
Depends on: 60966
Blocks:
  Show dependency tree
 
Reported: 2017-06-27 18:25 UTC by Pete Schmitz
Modified: 2018-03-05 16:44 UTC (History)
9 users (show)

Tags: android, label, fastrenderer
Is this bug a regression?: ---
Last known good build:


Attachments
Attempted reproduction of behavior (115.47 KB, application/x-zip-compressed)
2017-06-29 18:49 UTC, Pete Schmitz
Details


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 NOT_REPRODUCIBLE

Description Pete Schmitz 2017-06-27 18:25:52 UTC
A few of our users have encountered this exception over the last few days. 

First reports came in when we swapped to FormsAppCompatActivity and updated our forms package to 2.3.5-pre3. It appears to still be around in 2.3.5.255-pre5.

System.NotSupportedExceptionUnable to activate instance of type Xamarin.Forms.Platform.Android.FastRenderers.LabelRenderer from native handle 0x7fc1d0ffc4 (key_handle 0x15496f8).
Raw
Java.Interop.TypeManager.CreateInstance(IntPtr handle, JniHandleOwnership transfer, Type targetType)<7c760848680f44da9acbbc9da073b593>:0
Java.Lang.Object.GetObject(IntPtr handle, JniHandleOwnership transfer, Type type)<7c760848680f44da9acbbc9da073b593>:0
Java.Lang.Object._GetObject<T>(IntPtr handle, JniHandleOwnership transfer)<7c760848680f44da9acbbc9da073b593>:0
Java.Lang.Object.GetObject<T>(IntPtr handle, JniHandleOwnership transfer)<7c760848680f44da9acbbc9da073b593>:0
Java.Lang.Object.GetObject<T>(IntPtr jnienv, IntPtr handle, JniHandleOwnership transfer)<7c760848680f44da9acbbc9da073b593>:0
Android.Views.View.n_Invalidate(IntPtr jnienv, IntPtr native__this)<7c760848680f44da9acbbc9da073b593>:0
at (wrapper dynamic-method) System.Object:a7e7cf44-0e05-4cb3-9774-f23a6a5ffea6 (intptr,intptr)
System.MissingMethodExceptionNo constructor found for Xamarin.Forms.Platform.Android.FastRenderers.LabelRenderer::.ctor(System.IntPtr, Android.Runtime.JniHandleOwnership)

We've dealt with similar "No Constructor" stacks in the past, and the quick work-around was to sub-class the offending renderer and add the (ptr,handle) constructor. 

https://stackoverflow.com/questions/42254083/missingmethodexception-no-constructor-found-for-xamarin-forms-maps-android-map

Is this an advisable work-around for FastRenderers.LabelRenderers?

Regards,
Pete
Comment 1 David Ortinau [MSFT] 2017-06-28 20:22:00 UTC
Thanks for the report Pete, 

In order to look closer at this we need a project that demonstrates the issue. Please attach one to the ticket here and we'll investigate.
Comment 2 Pete Schmitz 2017-06-29 18:49:50 UTC
Created attachment 23223 [details]
Attempted reproduction of behavior

Attaching a potential repro project that mimics our app's form-implementation and simulates listview/label change.

As this problem is probably GC-related, it is very difficult to reproduce.

Resolved but similar old issue: https://bugzilla.xamarin.com/show_bug.cgi?id=32462

Full stack:

System.NotSupportedException Unable to activate instance of type Xamarin.Forms.Platform.Android.FastRenderers.LabelRenderer from native handle 0xaf200019 (key_handle 0x421461f8).

Java.Interop.TypeManager.CreateInstance(IntPtr handle, JniHandleOwnership transfer, Type targetType)<f2c2ee5afccb4d61b4c7c04f2fcd4aa8>:0
Java.Lang.Object.GetObject(IntPtr handle, JniHandleOwnership transfer, Type type)<f2c2ee5afccb4d61b4c7c04f2fcd4aa8>:0
Java.Lang.Object._GetObject<T>(IntPtr handle, JniHandleOwnership transfer)<f2c2ee5afccb4d61b4c7c04f2fcd4aa8>:0
Java.Lang.Object.GetObject<T>(IntPtr handle, JniHandleOwnership transfer)<f2c2ee5afccb4d61b4c7c04f2fcd4aa8>:0
Java.Lang.Object.GetObject<T>(IntPtr jnienv, IntPtr handle, JniHandleOwnership transfer)<f2c2ee5afccb4d61b4c7c04f2fcd4aa8>:0
Android.Views.View.n_Invalidate(IntPtr jnienv, IntPtr native__this)<f2c2ee5afccb4d61b4c7c04f2fcd4aa8>:0
at (wrapper dynamic-method) System.Object:1949db9c-5f72-47cd-9a1c-833c64af513a (intptr,intptr)

System.MissingMethodException No constructor found for Xamarin.Forms.Platform.Android.FastRenderers.LabelRenderer::.ctor(System.IntPtr, Android.Runtime.JniHandleOwnership)

Java.Interop.TypeManager.CreateProxy(Type type, IntPtr handle, JniHandleOwnership transfer)<f2c2ee5afccb4d61b4c7c04f2fcd4aa8>:0
Java.Interop.TypeManager.CreateInstance(IntPtr handle, JniHandleOwnership transfer, Type targetType)<f2c2ee5afccb4d61b4c7c04f2fcd4aa8>:0

Java.Lang.Error Exception of type 'Java.Interop.JavaLocationException' was thrown.

Java.Lang.Error: Exception of type 'Java.Lang.Error' was thrown.
--- End of managed Java.Lang.Error stack trace ---
java.lang.Error: Java callstack:
md5b60ffeb829f638581ab2bb9b1a7f4f3f.FormsTextView.n_invalidate(Native Method)
at md5b60ffeb829f638581ab2bb9b1a7f4f3f.FormsTextView.invalidate(FormsTextView.java:45)
at android.view.ViewRootImpl$InvalidateOnAnimationRunnable.run(ViewRootImpl.java:6095)
at android.view.Choreographer$CallbackRecord.run(Choreographer.java:761)
at android.view.Choreographer.doCallbacks(Choreographer.java:574)
at android.view.Choreographer.doFrame(Choreographer.java:543)
at android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:747)
at android.os.Handler.handleCallback(Handler.java:733)
at android.os.Handler.dispatchMessage(Handler.java:95)
at android.os.Looper.loop(Looper.java:136)
at android.app.ActivityThread.main(ActivityThread.java:5584)
java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:515)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1268)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1084)
dalvik.system.NativeStart.main(Native Method)
Comment 3 Samantha Houts [MSFT] 2017-08-03 19:01:37 UTC
@Pete Schmitz: Can you test with the latest nightly build and see if your issue is resolved?

Thank you!
Comment 4 Pete Schmitz 2017-08-03 20:16:01 UTC
Sorry for not updating sooner - Our prod builds are no longer encountering this error after throwing in a dummy custom renderer with requested constructor. 

Not sure if this is a recommended solution, but appears to have resolved our issue for now.

Regards,
Pete Schmitz

[assembly: ExportRenderer(typeof(CustomLabel), typeof(CustomLabelRenderer_Android))]
namespace iSurvey.Android
{
    public class CustomLabelRenderer_Android : Xamarin.Forms.Platform.Android.FastRenderers.LabelRenderer
    {
        public CustomLabelRenderer_Android(IntPtr a, JniHandleOwnership b) : base() {
        }

        public CustomLabelRenderer_Android() : base() {
        }
    }
}
Comment 5 Paul DiPietro [MSFT] 2017-09-08 14:12:22 UTC
I don't believe this is still an issue based on the repro working with the 2.4.0-pre2 build, so I'll close this for now. If there's any error and the problem still exists, please reopen this with a new reproduction if possible.
Comment 6 Pete Schmitz 2017-10-20 16:36:40 UTC
We have beta users encountering this exception. 

We've updated to 2.4.0, which forced us to remove the above workaround since the renderers are sealed.

Forms: Xamarin.Forms.2.4.0.282
Target Framework: 7.1
FormsAppCompatActivity
Forms.SetFlags("FastRenderers_Experimental");
global::Xamarin.Forms.Forms.Init (this, bundle);
Comment 7 Pete Schmitz 2017-10-20 16:39:12 UTC
Stack (identical from above)

System.NotSupportedException Unable to activate instance of type Xamarin.Forms.Platform.Android.FastRenderers.LabelRenderer from native handle 0x7fc0cda9e4 (key_handle 0x5f0addd).
Raw
Java.Interop.TypeManager.CreateInstance(IntPtr handle, JniHandleOwnership transfer, Type targetType)<46343d775b7c418183de9c17904b147e>:0
Java.Lang.Object.GetObject(IntPtr handle, JniHandleOwnership transfer, Type type)<46343d775b7c418183de9c17904b147e>:0
Java.Lang.Object._GetObject<T>(IntPtr handle, JniHandleOwnership transfer)<46343d775b7c418183de9c17904b147e>:0
Java.Lang.Object.GetObject<T>(IntPtr handle, JniHandleOwnership transfer)<46343d775b7c418183de9c17904b147e>:0
Java.Lang.Object.GetObject<T>(IntPtr jnienv, IntPtr handle, JniHandleOwnership transfer)<46343d775b7c418183de9c17904b147e>:0
Android.Views.View.n_Invalidate(IntPtr jnienv, IntPtr native__this)<46343d775b7c418183de9c17904b147e>:0
at (wrapper dynamic-method) System.Object:8c5475af-0d37-4e66-ad9e-707df7878169 (intptr,intptr)
System.MissingMethodExceptionNo constructor found for Xamarin.Forms.Platform.Android.FastRenderers.LabelRenderer::.ctor(System.IntPtr, Android.Runtime.JniHandleOwnership)
Java.Interop.TypeManager.CreateProxy(Type type, IntPtr handle, JniHandleOwnership transfer)<46343d775b7c418183de9c17904b147e>:0
Java.Interop.TypeManager.CreateInstance(IntPtr handle, JniHandleOwnership transfer, Type targetType)<46343d775b7c418183de9c17904b147e>: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 Java.Lang.Error stack trace ---
java.lang.Error: Java callstack:
md5b60ffeb829f638581ab2bb9b1a7f4f3f.FormsTextView.n_invalidate(Native Method)
at md5b60ffeb829f638581ab2bb9b1a7f4f3f.FormsTextView.invalidate(FormsTextView.java:45)
at android.view.ViewRootImpl$InvalidateOnAnimationRunnable.run(ViewRootImpl.java:7154)
at android.view.Choreographer$CallbackRecord.run(Choreographer.java:927)
at android.view.Choreographer.doCallbacks(Choreographer.java:702)
at android.view.Choreographer.doFrame(Choreographer.java:635)
at android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:913)
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:6688)
java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1468)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1358)
Comment 8 Björn Bentmar 2017-11-01 10:36:05 UTC
This is also blocking me from using Fastrenderers.
This crash occurs when popping a page.
Comment 9 Björn Bentmar 2017-11-01 11:12:43 UTC
Xamarin Exception Stack:
System.NotSupportedException: Unable to activate instance of type Xamarin.Forms.Platform.Android.FastRenderers.LabelRenderer from native handle 0xffb935bc (key_handle 0x6a36326).
  at Java.Interop.TypeManager.CreateInstance (System.IntPtr handle, Android.Runtime.JniHandleOwnership transfer, System.Type targetType) [0x0017d] in <96bcd00aafd8423b821e4431f6cb9f3d>:0
  at Java.Lang.Object.GetObject (System.IntPtr handle, Android.Runtime.JniHandleOwnership transfer, System.Type type) [0x000b9] in <96bcd00aafd8423b821e4431f6cb9f3d>:0
  at Java.Lang.Object._GetObject[T] (System.IntPtr handle, Android.Runtime.JniHandleOwnership transfer) [0x00017] in <96bcd00aafd8423b821e4431f6cb9f3d>:0
  at Java.Lang.Object.GetObject[T] (System.IntPtr handle, Android.Runtime.JniHandleOwnership transfer) [0x00000] in <96bcd00aafd8423b821e4431f6cb9f3d>:0
  at Java.Lang.Object.GetObject[T] (System.IntPtr jnienv, System.IntPtr handle, Android.Runtime.JniHandleOwnership transfer) [0x00006] in <96bcd00aafd8423b821e4431f6cb9f3d>:0
  at Android.Views.View.n_Invalidate (System.IntPtr jnienv, System.IntPtr native__this) [0x00000] in <96bcd00aafd8423b821e4431f6cb9f3d>:0
  at (wrapper dynamic-method) System.Object:1c2f4dfb-0ca3-452c-a2d7-4607e10d2f3a (intptr,intptr)
--- End of inner exception stack trace ---
  System.MissingMethodException: No constructor found for Xamarin.Forms.Platform.Android.FastRenderers.LabelRenderer::.ctor(System.IntPtr, Android.Runtime.JniHandleOwnership)
    at Java.Interop.TypeManager.CreateProxy (System.Type type, System.IntPtr handle, Android.Runtime.JniHandleOwnership transfer) [0x00054] in <96bcd00aafd8423b821e4431f6cb9f3d>:0
    at Java.Interop.TypeManager.CreateInstance (System.IntPtr handle, Android.Runtime.JniHandleOwnership transfer, System.Type targetType) [0x00111] in <96bcd00aafd8423b821e4431f6cb9f3d>:0
  --- End of inner exception stack trace ---
    Java.Interop.JavaLocationException: Exception of type 'Java.Interop.JavaLocationException' was thrown.
      at Java.Lang.Error: Exception of type 'Java.Lang.Error' was thrown.
      at java.lang.Error: Java callstack:
      at md5b60ffeb829f638581ab2bb9b1a7f4f3f.FormsTextView.n_invalidate(Native Method)
      at md5b60ffeb829f638581ab2bb9b1a7f4f3f.FormsTextView.invalidate(FormsTextView.java:45)
      at android.view.ViewRootImpl$InvalidateOnAnimationRunnable.run(ViewRootImpl.java:7233)
      at android.view.Choreographer$CallbackRecord.run(Choreographer.java:927)
      at android.view.Choreographer.doCallbacks(Choreographer.java:702)
      at android.view.Choreographer.doFrame(Choreographer.java:635)
      at android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:913)
      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:6836)
      at java.lang.reflect.Method.invoke(Native Method)
      at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1520)
      at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1410)

Thread 18281:
0   java.lang.Object.wait(Object.java:-2)
1   java.lang.Daemons$ReferenceQueueDaemon.run(Daemons.java:150)
2   java.lang.Thread.run(Thread.java:762)

Thread 18282:
0   java.lang.Object.wait(Object.java:-2)
1   java.lang.Object.wait(Object.java:407)
2   java.lang.ref.ReferenceQueue.remove(ReferenceQueue.java:188)
3   java.lang.ref.ReferenceQueue.remove(ReferenceQueue.java:209)
4   java.lang.Daemons$FinalizerDaemon.run(Daemons.java:204)
5   java.lang.Thread.run(Thread.java:762)

Thread 18283:
0   java.lang.Object.wait(Object.java:-2)
1   java.lang.Daemons$FinalizerWatchdogDaemon.sleepUntilNeeded(Daemons.java:269)
2   java.lang.Daemons$FinalizerWatchdogDaemon.run(Daemons.java:249)
3   java.lang.Thread.run(Thread.java:762)

Thread 18284:
0   dalvik.system.VMRuntime.runHeapTasks(VMRuntime.java:-2)
1   java.lang.Daemons$HeapTaskDaemon.run(Daemons.java:433)
2   java.lang.Thread.run(Thread.java:762)

Thread 18295:
0   android.os.MessageQueue.nativePollOnce(MessageQueue.java:-2)
1   android.os.MessageQueue.next(MessageQueue.java:323)
2   android.os.Looper.loop(Looper.java:136)
3   android.os.HandlerThread.run(HandlerThread.java:61)

Thread 18297:
0   java.lang.Object.wait(Object.java:-2)
1   java.lang.Thread.parkFor$(Thread.java:2128)
2   sun.misc.Unsafe.park(Unsafe.java:325)
3   java.util.concurrent.locks.LockSupport.park(LockSupport.java:161)
4   java.util.concurrent.locks.AbstractQueuedSynchronizer$ConditionObject.await(AbstractQueuedSynchronizer.java:2035)
5   java.util.concurrent.LinkedBlockingQueue.take(LinkedBlockingQueue.java:413)
6   java.util.concurrent.ThreadPoolExecutor.getTask(ThreadPoolExecutor.java:1058)
7   java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1118)
8   java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:607)
9   java.lang.Thread.run(Thread.java:762)

Thread 18303:
0   java.lang.Object.wait(Object.java:-2)
1   com.android.okhttp.okio.AsyncTimeout.awaitTimeout(AsyncTimeout.java:323)
2   com.android.okhttp.okio.AsyncTimeout.-wrap0(AsyncTimeout.java:-1)
3   com.android.okhttp.okio.AsyncTimeout$Watchdog.run(AsyncTimeout.java:286)

Thread 21637:
0   java.lang.Object.wait(Object.java:-2)
1   com.android.okhttp.ConnectionPool.performCleanup(ConnectionPool.java:319)
2   com.android.okhttp.ConnectionPool.runCleanupUntilPoolIsEmpty(ConnectionPool.java:256)
3   com.android.okhttp.ConnectionPool.-wrap0(ConnectionPool.java:-1)
4   com.android.okhttp.ConnectionPool$1.run(ConnectionPool.java:102)
5   java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1133)
6   java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:607)
7   java.lang.Thread.run(Thread.java:762)

Thread 23166:
0   java.lang.Object.wait(Object.java:-2)
1   java.lang.Thread.parkFor$(Thread.java:2128)
2   sun.misc.Unsafe.park(Unsafe.java:325)
3   java.util.concurrent.locks.LockSupport.parkNanos(LockSupport.java:201)
4   java.util.concurrent.locks.AbstractQueuedSynchronizer$ConditionObject.awaitNanos(AbstractQueuedSynchronizer.java:2077)
5   java.util.concurrent.LinkedBlockingQueue.poll(LinkedBlockingQueue.java:438)
6   java.util.concurrent.ThreadPoolExecutor.getTask(ThreadPoolExecutor.java:1057)
7   java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1118)
8   java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:607)
9   java.lang.Thread.run(Thread.java:762)

Thread 23167:
0   java.lang.Object.wait(Object.java:-2)
1   java.lang.Thread.parkFor$(Thread.java:2128)
2   sun.misc.Unsafe.park(Unsafe.java:325)
3   java.util.concurrent.locks.LockSupport.parkNanos(LockSupport.java:201)
4   java.util.concurrent.locks.AbstractQueuedSynchronizer$ConditionObject.awaitNanos(AbstractQueuedSynchronizer.java:2077)
5   java.util.concurrent.LinkedBlockingQueue.poll(LinkedBlockingQueue.java:438)
6   java.util.concurrent.ThreadPoolExecutor.getTask(ThreadPoolExecutor.java:1057)
7   java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1118)
8   java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:607)
9   java.lang.Thread.run(Thread.java:762)

Thread 23169:
0   java.lang.Object.wait(Object.java:-2)
1   java.lang.Thread.parkFor$(Thread.java:2128)
2   sun.misc.Unsafe.park(Unsafe.java:325)
3   java.util.concurrent.locks.LockSupport.parkNanos(LockSupport.java:201)
4   java.util.concurrent.locks.AbstractQueuedSynchronizer$ConditionObject.awaitNanos(AbstractQueuedSynchronizer.java:2077)
5   java.util.concurrent.LinkedBlockingQueue.poll(LinkedBlockingQueue.java:438)
6   java.util.concurrent.ThreadPoolExecutor.getTask(ThreadPoolExecutor.java:1057)
7   java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1118)
8   java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:607)
9   java.lang.Thread.run(Thread.java:762)
Comment 10 Pete Schmitz 2017-11-08 21:53:44 UTC
We have several users reporting this issue when popping a page from the navigation stack. 

Some devices appear to hit this more frequent than others - One user on Android M, BLU Life One X2 is hitting a similar FastRenderer exception (ImageRenderer) consistently:

android.runtime.JavaProxyThrowable: System.NotSupportedException: Unable to activate instance of type Xamarin.Forms.Platform.Android.FastRenderers.ImageRenderer from native handle 0x7fd8a0fad4 (key_handle 0xa0cd4f3). ---> System.MissingMethodException: No constructor found for Xamarin.Forms.Platform.Android.FastRenderers.ImageRenderer::.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 <d5a53adfefe243d28a3b121c149d7867>:0 
  at Java.Interop.TypeManager.CreateInstance (System.IntPtr handle, Android.Runtime.JniHandleOwnership transfer, System.Type targetType) [0x00111] in <d5a53adfefe243d28a3b121c149d7867>:0 
   --- End of inner exception stack trace ---
  at Java.Interop.TypeManager.CreateInstance (System.IntPtr handle, Android.Runtime.JniHandleOwnership transfer, System.Type targetType) [0x0017d] in <d5a53adfefe243d28a3b121c149d7867>:0 
  at Java.Lang.Object.GetObject (System.IntPtr handle, Android.Runtime.JniHandleOwnership transfer, System.Type type) [0x000b9] in <d5a53adfefe243d28a3b121c149d7867>:0 
  at Java.Lang.Object._GetObject[T] (System.IntPtr handle, Android.Runtime.JniHandleOwnership transfer) [0x00017] in <d5a53adfefe243d28a3b121c149d7867>:0 
  at Java.Lang.Object.GetObject[T] (System.IntPtr handle, Android.Runtime.JniHandleOwnership transfer) [0x00000] in <d5a53adfefe243d28a3b121c149d7867>:0 
  at Java.Lang.Object.GetObject[T] (System.IntPtr jnienv, System.IntPtr handle, Android.Runtime.JniHandleOwnership transfer) [0x00006] in <d5a53adfefe243d28a3b121c149d7867>:0 
  at Android.Views.View.n_Invalidate (System.IntPtr jnienv, System.IntPtr native__this) [0x00000] in <d5a53adfefe243d28a3b121c149d7867>:0 
  at (wrapper dynamic-method) System.Object:11a52cdb-1443-4cf2-9651-b3b5ce1629b5 (intptr,intptr)
--- End of stack trace from previous location where exception was thrown ---
  at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw () [0x0000c] in <9b835887552f49368f731561e631e321>:0 
  at Java.Interop.JniEnvironment+InstanceMethods.CallNonvirtualVoidMethod (Java.Interop.JniObjectReference instance, Java.Interop.JniObjectReference type, Java.Interop.JniMethodInfo method, Java.Interop.JniArgumentValue* args) [0x00089] in <cc740dc8bd83419d8d7db8ab118de43b>:0 
  at Java.Interop.JniPeerMembers+JniInstanceMethods.InvokeVirtualVoidMethod (System.String encodedMember, Java.Interop.IJavaPeerable self, Java.Interop.JniArgumentValue* parameters) [0x0005d] in <cc740dc8bd83419d8d7db8ab118de43b>:0 
  at Android.Views.ViewGroup.RemoveAllViews () [0x0000a] in <d5a53adfefe243d28a3b121c149d7867>:0 
  at Xamarin.Forms.Platform.Android.VisualElementRenderer`1[TElement].Dispose (System.Boolean disposing) [0x00088] in <8d6936257ac5419f8be9df07a9bb5129>:0 
  at Java.Lang.Object.Dispose () [0x00000] in <d5a53adfefe243d28a3b121c149d7867>:0 
  at Xamarin.Forms.Platform.Android.VisualElementRenderer`1[TElement].Dispose (System.Boolean disposing) [0x0007b] in <8d6936257ac5419f8be9df07a9bb5129>:0 
  at Java.Lang.Object.Dispose () [0x00000] in <d5a53adfefe243d28a3b121c149d7867>:0 
  at Xamarin.Forms.Platform.Android.VisualElementRenderer`1[TElement].Dispose (System.Boolean disposing) [0x0007b] in <8d6936257ac5419f8be9df07a9bb5129>:0 
  at Java.Lang.Object.Dispose () [0x00000] in <d5a53adfefe243d28a3b121c149d7867>:0 
  at Xamarin.Forms.Platform.Android.ListViewRenderer.ClearRenderer (Android.Views.View renderedView) [0x00036] in <8d6936257ac5419f8be9df07a9bb5129>:0 
  at Xamarin.Forms.Platform.Android.ListViewRenderer.Dispose (System.Boolean disposing) [0x0002a] in <8d6936257ac5419f8be9df07a9bb5129>:0 
  at Java.Lang.Object.Dispose () [0x00000] in <d5a53adfefe243d28a3b121c149d7867>:0 
  at Xamarin.Forms.Platform.Android.VisualElementRenderer`1[TElement].Dispose (System.Boolean disposing) [0x0007b] in <8d6936257ac5419f8be9df07a9bb5129>:0 
  at Java.Lang.Object.Dispose () [0x00000] in <d5a53adfefe243d28a3b121c149d7867>:0 
  at Xamarin.Forms.Platform.Android.VisualElementRenderer`1[TElement].Dispose (System.Boolean disposing) [0x0007b] in <8d6936257ac5419f8be9df07a9bb5129>:0 
  at Java.Lang.Object.Dispose () [0x00000] in <d5a53adfefe243d28a3b121c149d7867>:0 
  at Xamarin.Forms.Platform.Android.VisualElementRenderer`1[TElement].Dispose (System.Boolean disposing) [0x0007b] in <8d6936257ac5419f8be9df07a9bb5129>:0 
  at Java.Lang.Object.Dispose () [0x00000] in <d5a53adfefe243d28a3b121c149d7867>:0 
  at Xamarin.Forms.Platform.Android.VisualElementRenderer`1[TElement].Dispose (System.Boolean disposing) [0x0007b] in <8d6936257ac5419f8be9df07a9bb5129>:0 
  at Xamarin.Forms.Platform.Android.PageRenderer.Dispose (System.Boolean disposing) [0x00011] in <8d6936257ac5419f8be9df07a9bb5129>:0 
  at Java.Lang.Object.Dispose () [0x00000] in <d5a53adfefe243d28a3b121c149d7867>:0 
  at Xamarin.Forms.Platform.Android.AppCompat.FragmentContainer.OnDestroyView () [0x0003c] in <8d6936257ac5419f8be9df07a9bb5129>:0 
  at Android.Support.V4.App.Fragment.n_OnDestroyView (System.IntPtr jnienv, System.IntPtr native__this) [0x00008] in <1e89c43d3c7d48b5ba69bfc0b1bdf114>:0 
  at (wrapper dynamic-method) System.Object:8c728c68-491d-438a-9fa1-5f9d47a610d4 (intptr,intptr)
	at md5270abb39e60627f0f200893b490a1ade.FragmentContainer.n_onDestroyView(Native Method)
	at md5270abb39e60627f0f200893b490a1ade.FragmentContainer.onDestroyView(FragmentContainer.java:59)
	at android.support.v4.app.Fragment.performDestroyView(Fragment.java:2480)
	at android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:1422)
	at android.support.v4.app.FragmentManagerImpl.moveFragmentToExpectedState(FragmentManager.java:1569)
	at android.support.v4.app.BackStackRecord.executeOps(BackStackRecord.java:753)
	at android.support.v4.app.FragmentManagerImpl.executeOps(FragmentManager.java:2415)
	at android.support.v4.app.FragmentManagerImpl.executeOpsTogether(FragmentManager.java:2201)
	at android.support.v4.app.FragmentManagerImpl.optimizeAndExecuteOps(FragmentManager.java:2155)
	at android.support.v4.app.FragmentManagerImpl.execPendingActions(FragmentManager.java:2064)
	at android.support.v4.app.FragmentManagerImpl$1.run(FragmentManager.java:718)
	at android.os.Handler.handleCallback(Handler.java:739)
	at android.os.Handler.dispatchMessage(Handler.java:95)
	at android.os.Looper.loop(Looper.java:158)
	at android.app.ActivityThread.main(ActivityThread.java:7229)
	at java.lang.reflect.Method.invoke(Native Method)
	at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1230)
	at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1120)
Comment 11 Pete Schmitz 2017-11-15 17:20:09 UTC
Can we receive some official word regarding this issue please? In 2.4.0, fast renderers became sealed - this prevents the workaround we had in place. Disabling fast renderers introduces regression variants of "System.NotSupportedException Unable to activate instance" crashes on other renderers, including:

Xamarin.Forms.Platform.Android.Platform+DefaultRenderer

Similar issues are well document and reported, consistently, for well over a year:

https://bugzilla.xamarin.com/show_bug.cgi?id=40258

https://bugzilla.xamarin.com/show_bug.cgi?id=39451

I'm aware there are further renderer optimizations in 2.5 - should these problems finally be resolved in 2.5?

I apologize for the insistence of a response, however this issue is affecting our production application.
Comment 12 Paul DiPietro [MSFT] 2017-11-15 19:27:21 UTC
We have just declared 2.5 as stable, so I would suggest testing this as soon as you are able. If this still occurs, please let us know exactly which devices the issue is being experienced on, if different from ones mentioned prior. The original reproduction doesn't appear to cause a crash on a local S8 device with the flags enabled.
Comment 13 Pete Schmitz 2017-11-15 19:36:11 UTC
Paul, thanks for the fast reply - We'll migrate over to 2.5 and begin testing.
Comment 14 Pete Schmitz 2017-11-27 17:45:15 UTC
Unfortunately, after updating to 2.5, two custom renderers still appear to encounter this exception - LabelRenderer and BoxRenderer.

Their implementation is quite simple (and perhaps redundant with the deprecation of the handle + transfer constructor):

https://hastebin.com/yonudazose.cs

https://hastebin.com/agigupesas.cs

Both stacks are identical, propagating from FragmentContainer.n_onDestroyView(Native Method)

System.NotSupportedExceptionUnable to activate instance of type iSurvey.Android.CustomLabelRenderer_Android from native handle 0x7fe946c8d4 (key_handle 0xe4937ea).
Raw
Java.Interop.TypeManager.CreateInstance(IntPtr handle, JniHandleOwnership transfer, Type targetType)<ca280c8f283d4d71aae375bb09398dd6>:0
Java.Lang.Object.GetObject(IntPtr handle, JniHandleOwnership transfer, Type type)<ca280c8f283d4d71aae375bb09398dd6>:0
Java.Lang.Object._GetObject<T>(IntPtr handle, JniHandleOwnership transfer)<ca280c8f283d4d71aae375bb09398dd6>:0
Java.Lang.Object.GetObject<T>(IntPtr handle, JniHandleOwnership transfer)<ca280c8f283d4d71aae375bb09398dd6>:0
Java.Lang.Object.GetObject<T>(IntPtr jnienv, IntPtr handle, JniHandleOwnership transfer)<ca280c8f283d4d71aae375bb09398dd6>:0
Android.Views.View.n_DispatchTouchEvent_Landroid_view_MotionEvent_(IntPtr jnienv, IntPtr native__this, IntPtr native_e)<ca280c8f283d4d71aae375bb09398dd6>:0
at (wrapper dynamic-method) System.Object:4624d790-469a-4d69-a35f-f93786d70d99 (intptr,intptr,intptr)
System.MissingMethodExceptionNo constructor found for iSurvey.Android.CustomLabelRenderer_Android::.ctor(System.IntPtr, Android.Runtime.JniHandleOwnership)
Java.Interop.TypeManager.CreateProxy(Type type, IntPtr handle, JniHandleOwnership transfer)<ca280c8f283d4d71aae375bb09398dd6>:0
Java.Interop.TypeManager.CreateInstance(IntPtr handle, JniHandleOwnership transfer, Type targetType)<ca280c8f283d4d71aae375bb09398dd6>:0

Inner:

Java.Lang.ErrorException of type 'Java.Interop.JavaLocationException' was thrown.
Java.Lang.Error: Exception of type 'Java.Lang.Error' was thrown.
--- End of managed Java.Lang.Error stack trace ---
java.lang.Error: Java callstack:
md5b60ffeb829f638581ab2bb9b1a7f4f3f.VisualElementRenderer_1.n_dispatchTouchEvent(Native Method)
at md5b60ffeb829f638581ab2bb9b1a7f4f3f.VisualElementRenderer_1.dispatchTouchEvent(VisualElementRenderer_1.java:64)
at android.view.ViewGroup.cancelTouchTarget(ViewGroup.java:2452)
at android.view.ViewGroup.removeAllViewsInLayout(ViewGroup.java:4791)
at android.view.ViewGroup.removeAllViews(ViewGroup.java:4744)
md5270abb39e60627f0f200893b490a1ade.FragmentContainer.n_onDestroyView(Native Method)
at md5270abb39e60627f0f200893b490a1ade.FragmentContainer.onDestroyView(FragmentContainer.java:59)
at android.support.v4.app.Fragment.performDestroyView(Fragment.java:2480)
at android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:1422)
at android.support.v4.app.FragmentManagerImpl.moveFragmentToExpectedState(FragmentManager.java:1569)
at android.support.v4.app.BackStackRecord.executeOps(BackStackRecord.java:753)
at android.support.v4.app.FragmentManagerImpl.executeOps(FragmentManager.java:2415)
at android.support.v4.app.FragmentManagerImpl.executeOpsTogether(FragmentManager.java:2201)
at android.support.v4.app.FragmentManagerImpl.optimizeAndExecuteOps(FragmentManager.java:2155)
at android.support.v4.app.FragmentManagerImpl.execPendingActions(FragmentManager.java:2064)
at android.support.v4.app.FragmentManagerImpl$1.run(FragmentManager.java:718)
at android.os.Handler.handleCallback(Handler.java:739)
at android.os.Handler.dispatchMessage(Handler.java:95)
at android.os.Looper.loop(Looper.java:157)
at android.app.ActivityThread.main(ActivityThread.java:5428)
java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:726)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616)
Comment 15 Pete Schmitz 2017-12-08 00:14:18 UTC
This problem persists for our users in Forms 2.5.0.91635 for these renderers:

Xamarin.Forms.Platform.Android.BoxRenderer
Xamarin.Forms.Platform.Android.Platform+DefaultRenderer
Xamarin.Forms.Platform.Android.LabelRenderer

3% of our userbase is affected. 

Device sample:
LG-K540	6.7%
Z981	6.3%
SM-J327P	4.6%
LG-M153	4.6%
LGLS676	4.4%

Feedback from our users suggest the repro provided in comment #2 remains accurate (https://bugzilla.xamarin.com/show_bug.cgi?id=57802#c2)
Comment 16 Damir Beylkhanov 2017-12-12 09:41:59 UTC
the same issue for me. see below link with screenshot from VS App Center

https://www.dropbox.com/s/tigltqnegf5izfd/xamarin.android%20issue.PNG?dl=0
Comment 17 Damir Beylkhanov 2017-12-12 09:45:43 UTC
additional info to my previous comment:
XF stable release v.2.5.0
Comment 18 d.vanluijpen 2017-12-21 09:56:31 UTC
Tapping in on this bug. Experiencing the same issue regarding ImageRenderer on multiple devices. Occurs quit random it seems after popping a page from the stack, mostly when an action has occurred before, similar to changing an image of a button on the page that is popped. Disposing and setting the button to null in destructor did not help.

Testing on a physical device:
- Samsung Galaxy S5 Mini
- Android 6.0.1

Development Tools properties:
- Visual Studio for Mac ENTERPRISE
- Version 7.3.2 (build 12)
- Xamarin.Forms 2.5.0.121934
- Runtime:
	Mono 5.4.1.7 (2017-06/e66d9abbb27) (64-bit)
	GTK+ 2.24.23 (Raleigh theme)
- Xamarin.Android 
-- Version: 8.1.0.25 (Visual Studio Enterprise)
-- Installed SDKs API 15-26)
--SDK Tools Version: 25.2.5
--SDK Platform Tools Version: 27.0.0
--SDK Build Tools Version: 27.0.2

--Java SDK: /usr
--java version "1.8.0_101"
--Java(TM) SE Runtime Environment (build 1.8.0_101-b13)
--Java HotSpot(TM) 64-Bit Server VM (build 25.101-b13, mixed mode)


Some of the caught messages and stacktraces:


***
Unable to activate instance of type Xamarin.Forms.Platform.Android.FastRenderers.ImageRenderer


***
{System.MissingMethodException: No constructor found for Xamarin.Forms.Platform.Android.FastRenderers.ImageRenderer::.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 <28e323a707a2414f8b493f6d4bb27c8d>:0 
  at Java.Interop.TypeManager.CreateInstance (System.IntPtr handle, Android.Runtime.JniHandleOwnership transfer, System.Type targetType) [0x00111] in <28e323a707a2414f8b493f6d4bb27c8d>:0 }


***
Java.Lang.Error: Exception of type 'Java.Lang.Error' was thrown.
  --- End of managed Java.Lang.Error stack trace ---
java.lang.Error: Java callstack:
  at md57018357d52b54713cd814fbd5262dd1f.ImageRenderer.n_invalidate(Native Method)
  at md57018357d52b54713cd814fbd5262dd1f.ImageRenderer.invalidate(ImageRenderer.java:54)
  at android.widget.ImageView.invalidateDrawable(ImageView.java:262)
  at android.graphics.drawable.Drawable.invalidateSelf(Drawable.java:844)
  at android.graphics.drawable.Drawable.setVisible(Drawable.java:1575)
  at android.widget.ImageView.onDetachedFromWindow(ImageView.java:1511)
  at android.view.View.dispatchDetachedFromWindow(View.java:15916)
  at android.view.ViewGroup.removeAllViewsInLayout(ViewGroup.java:5141)
  at android.view.ViewGroup.removeAllViews(ViewGroup.java:5087)
  at md5270abb39e60627f0f200893b490a1ade.FragmentContainer.n_onDestroyView(Native Method)
  at md5270abb39e60627f0f200893b490a1ade.FragmentContainer.onDestroyView(FragmentContainer.java:59)
  at android.support.v4.app.Fragment.performDestroyView(Fragment.java:2590)
  at android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:1503)
  at android.support.v4.app.FragmentManagerImpl.moveFragmentToExpectedState(FragmentManager.java:1740)
  at android.support.v4.app.BackStackRecord.executeOps(BackStackRecord.java:794)
  at android.support.v4.app.FragmentManagerImpl.executeOps(FragmentManager.java:2580)
  at android.support.v4.app.FragmentManagerImpl.executeOpsTogether(FragmentManager.java:2367)
  at android.support.v4.app.FragmentManagerImpl.removeRedundantOperationsAndExecute(FragmentManager.java:2322)
  at android.support.v4.app.FragmentManagerImpl.execPendingActions(FragmentManager.java:2229)
  at android.support.v4.app.FragmentManagerImpl$1.run(FragmentManager.java:700)
  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:7331)
  at java.lang.reflect.Method.invoke(Native Method)
  at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1230)
  at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1120)
Comment 19 j.piechowiak 2018-02-08 17:19:02 UTC
I can confirm, that for me the problem also occurs with the newest stable version. 

The reproduction scenario is similair. Go on some page, do some actions, return to the previous one. Exception occurs in both cases - with turned on and off renderers. 
The issue is connected with missing constructor with signature: 
::.ctor(System.IntPtr, Android.Runtime.JniHandleOwnership)
Comment 20 Paul DiPietro [MSFT] 2018-03-05 16:44:44 UTC
I'm still unable to get a crash on an S8 running the latest 2.5.1-pre. It may be device or version dependent, but if any of you are still experiencing this, moving this issue over to GitHub (perhaps with an updated reproduction, with a different scenario causing the crash) would be appreciated.