No constructor found for Xamarin.Forms.Platform.Android.ScrollViewRenderer::.ctor

ChrisMcBrideChrisMcBride USMember ✭✭

On Android 4.4.2 sometimes I get:
Caused by: md52ce486a14f4bcd95899665e9d932190b.JavaProxyThrowable: System.NotSupportedException: Unable to activate instance of type Xamarin.Forms.Platform.Android.ScrollViewRenderer from native handle 3870001d ---> System.MissingMethodException: No constructor found for Xamarin.Forms.Platform.Android.ScrollViewRenderer::.ctor(System.IntPtr, Android.Runtime.JniHandleOwnership) ---> Java.Interop.JavaLocationException: Exception of type 'Java.Interop.JavaLocationException' was thrown. Java.Lang.Error: Exception of type 'Java.Lang.Error' was thrown.

These seems to happen only after an update to the app.
What is interesting is that seems to be happening when we are trying to destroy a view:

at md5530bd51e982e6e7b340b73e88efe666e.ScrollViewRenderer.n_onDetachedFromWindow(Native Method) at md5530bd51e982e6e7b340b73e88efe666e.ScrollViewRenderer.onDetachedFromWindow(ScrollViewRenderer.java:80) at android.view.View.dispatchDetachedFromWindow(View.java:12787) at android.view.ViewGroup.dispatchDetachedFromWindow(ViewGroup.java:2706) at android.view.ViewGroup.removeAllViewsInLayout(ViewGroup.java:4254) at android.view.ViewGroup.removeAllViews(ViewGroup.java:4186) at md5fb436084bbd4c8599b985da0bb24bd53.XFormsApplicationDroid.n_onDestroy(Native Method) at md5fb436084bbd4c8599b985da0bb24bd53.XFormsApplicationDroid.onDestroy(XFormsApplicationDroid.java:33) at android.app.Activity.performDestroy(Activity.java:5436) at android.app.Instrumentation.callActivityOnDestroy(Instrumentation.java:1119) at android.app.ActivityThread.performDestroyActivity(ActivityThread.java:3676) at android.app.ActivityThread.handleDestroyActivity(ActivityThread.java:3707) at android.app.ActivityThread.access$1400(ActivityThread.java:151) at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1374) ...

Answers

  • hghuahghua USMember ✭✭

    Same problem here
    The bug link: https://bugzilla.xamarin.com/show_bug.cgi?id=32462
    Hope Xamarin guys fix it soon

  • hghuahghua USMember ✭✭

    Anybody help?

  • AlexSAlexS USUniversity ✭✭✭

    We have the same problem.
    @Xamarin, please give us some feedback

  • TrevorCoxTrevorCox CAMember ✭✭

    I saw the same crash, also on Android 4.4, but with my subclass of Xamarin.Forms.Platform.Android.WebViewRenderer.

  • AdrianKnightAdrianKnight USMember ✭✭✭✭

    This hasn't been fixed. Why make people wait for months...

  • MatheusSilvaMatheusSilva USMember ✭✭

    Hi!
    I have the same issue with ListView -> "No constructor found for Xamarin.Forms.Platform.Android.ListViewAdapter::.ctor(System.IntPtr, Android.Runtime.JniHandleOwnership)"

    @ChrisMcBride any solution?

  • Hikari91Hikari91 ITMember ✭✭✭

    @Ma>; @MatheusSilva said:

    Hi!
    I have the same issue with ListView -> "No constructor found for Xamarin.Forms.Platform.Android.ListViewAdapter::.ctor(System.IntPtr, Android.Runtime.JniHandleOwnership)"

    @ChrisMcBride any solution?

    Same error here, the Android app crash always, did you find a solution?

  • RafaelAddessoRafaelAddesso BRMember ✭✭

    Any solution for this issue?

  • RafaelAddessoRafaelAddesso BRMember ✭✭

    I solved this by adding a new CustomRenderer on my android solution, as mentioned on @hghua bugzila link:

    using System;
    using Android.Runtime;
    using LetzInk.Droid.Custom.Renderer;
    using Xamarin.Forms;
    
    [assembly: ExportRenderer(typeof(Xamarin.Forms.ScrollView), typeof(ScrollViewRenderer))]
    namespace LetzInk.Droid.Custom.Renderer
    {
        public class ScrollViewRenderer : Xamarin.Forms.Platform.Android.ScrollViewRenderer
        {
            public ScrollViewRenderer()
            { }
    
            public ScrollViewRenderer(IntPtr javaReference, JniHandleOwnership transfer)
            { }
        }
    }
    

    Version used here for Xamarin Forms: 2.5.1.527436

  • bijingtonbijington Member ✭✭

    @RafaelAddesso while your solution may work it has to be considered a workaround due to the warnings that are introduced by using the default constructor for renderers that has been marked obsolete from version 2.5

  • KanthKanth INMember ✭✭
    edited September 4

    I am getting this issue in the webviewrenderer, Adding missing constructor is a proper solution ? If there is any other approach please suggest @bijington and @RafaelAddesso

Sign In or Register to comment.