Bug 37231 - Replacing MainPage from ContextAction Error - Xamarin.Forms.Platform.Android.ListViewAdapter
Summary: Replacing MainPage from ContextAction Error - Xamarin.Forms.Platform.Android....
Status: CONFIRMED
Alias: None
Product: Forms
Classification: Xamarin
Component: Forms ()
Version: 1.5.1
Hardware: PC Windows
: Normal critical
Target Milestone: ---
Assignee: Bugzilla
URL:
Depends on: 60966
Blocks:
  Show dependency tree
 
Reported: 2015-12-22 15:52 UTC by Paul Charlton
Modified: 2017-12-11 23:03 UTC (History)
7 users (show)

Tags: ac, contextaction, android, crash
Is this bug a regression?: ---
Last known good build:


Attachments
three files to highlight error (1.79 KB, application/zip)
2015-12-22 15:52 UTC, Paul Charlton
Details
Sample Project (288.39 KB, application/zip)
2016-01-14 14:09 UTC, Parmendra Kumar
Details
sample files, fixed collection issue (1.90 KB, application/zip)
2016-01-14 14:17 UTC, Paul Charlton
Details
Full sample project (6.30 MB, application/zip)
2016-01-18 11:03 UTC, Paul Charlton
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 for Bug 37231 on Developer Community or GitHub if you have new information to add and do not yet see a matching new report.

If the latest results still closely match this report, you can use the original description:

  • Export the original title and description: Developer Community HTML or GitHub Markdown
  • Copy the title and description into the new report. Adjust them to be up-to-date if needed.
  • Add your new information.

In special cases on GitHub you might also want the comments: GitHub Markdown with public comments

Related Links:
Status:
CONFIRMED

Description Paul Charlton 2015-12-22 15:52:15 UTC
Created attachment 14379 [details]
three files to highlight error

Hi,
When using a ContextAction to navigate in an app, by replacing the MainPage, an exception occurs, stack trace at the end. (Depending on forms version, get differerent stack trace, pasted two below).

I've attached three files from a sample app that highlight the error:
-long click to get action menu, 
-select the "Error Me" option,
-it should crash.  

I've currently only tried this in Forms 1.5.1 so not sure if it still effects later version.

As a workaround the code to replace the MainPage can be ran from an awaited task and this works.

Thanks in advance,
Paul.

12-22 15:32:17.690 I/MonoDroid(11013): UNHANDLED EXCEPTION:
12-22 15:32:17.710 I/MonoDroid(11013): System.NotSupportedException: Unable to activate instance of type Xamarin.Forms.Platform.Android.ListViewAdapter from native handle a1d00019 ---> 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.
12-22 15:32:17.710 I/MonoDroid(11013): Java.Lang.Error: Exception of type 'Java.Lang.Error' was thrown.
12-22 15:32:17.710 I/MonoDroid(11013):   --- End of managed exception stack trace ---
12-22 15:32:17.710 I/MonoDroid(11013): java.lang.Error: Java callstack:
12-22 15:32:17.710 I/MonoDroid(11013): 	at md5d4dd78677dce656d5db26c85a3743ef3.CellAdapter.n_onDestroyActionMode(Native Method)
12-22 15:32:17.710 I/MonoDroid(11013): 	at com.android.internal.policy.impl.PhoneWindow$DecorView$ActionModeCallbackWrapper.onDestroyActionMode(PhoneWindow.java:3033)
12-22 15:32:17.710 I/MonoDroid(11013): 	at com.android.internal.app.ActionBarImpl.completeDeferredDestroyActionMode(ActionBarImpl.java:302)
12-22 15:32:17.710 I/MonoDroid(11013): 	at com.android.internal.app.ActionBarImpl$1.onAnimationEnd(ActionBarImpl.java:140)
12-22 15:32:17.710 I/MonoDroid(11013): 	at android.animation.AnimatorSet$AnimatorSetListener.onAnimationEnd(AnimatorSet.java:818)
12-22 15:32:17.710 I/MonoDroid(11013): 	at android.animation.ValueAnimator.endAnimation(ValueAnimator.java:1056)
12-22 15:32:17.710 I/MonoDroid(11013): 	at android.animation.ValueAnimator.access$400(ValueAnimator.java:50)
12-22 15:32:17.710 I/MonoDroid(11013): 	at android.view.Choreographer$CallbackRecord.run(Choreographer.java:813)
12-22 15:32:17.710 I/MonoDroid(11013): 	at android.view.Choreographer.doCallbacks(Choreographer.java:613)
12-22 15:32:17.710 I/MonoDroid(11013): 	at android.view.Choreographer.doFrame(Choreographer.java:582)
12-22 15:32:17.710 I/MonoDroid(11013): 	at android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:799)
12-22 15:32:17.710 I/MonoDroid(11013): 	at android.os.Handler.handleCallback(Handler.java:733)
12-22 15:32:17.710 I/MonoDroid(11013): 	at android.os.Handler.dispatchMessage(Handler.java:95)
12-22 15:32:17.710 I/MonoDroid(11013): 	at android.os.Looper.loop(Looper.java:146)
12-22 15:32:17.710 I/MonoDroid(11013): 	at android.app.ActivityThread.main(ActivityThread.java:5598)
12-22 15:32:17.710 I/MonoDroid(11013): 	at java.lang.reflect.Method.invokeNative(Native Method)
12-22 15:32:17.710 I/MonoDroid(11013): 	at java.lang.reflect.Method.invoke(Method.java:515)
12-22 15:32:17.710 I/MonoDroid(11013): 	at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1283)
12-22 15:32:17.710 I/MonoDroid(11013): 	at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1099)
12-22 15:32:17.710 I/MonoDroid(11013): 	at dalvik.system.NativeStart.main(Native Method)
12-22 15:32:17.710 I/MonoDroid(11013):   --- End of inner exception stack trace ---
12-22 15:32:17.710 I/MonoDroid(11013):   at Java.Interop.TypeManager.CreateProxy (System.Type type, IntPtr handle, JniHandleOwnership transfer) [0x00058] in <filename unknown>:0 
12-22 15:32:17.710 I/MonoDroid(11013):   at Java.Interop.TypeManager.CreateInstance (IntPtr handle, JniHandleOwnership transfer, System.Type targetType) [0x001ea] in <filename unknown>:0 
12-22 15:32:17.710 I/MonoDroid(11013):   --- End of inner exception stack trace ---
12-22 15:32:17.710 I/MonoDroid(11013): at Java.Interop.TypeManager.CreateInstance (intptr,Android.Runtime.JniHandleOwnership,System.Type) <IL 0x00260, 0x013cc>
12-22 15:32:17.710 I/MonoDroid(11013): at Java.Lang.Object.GetObject (intptr,Android.Runtime.JniHandleOwnership,System.Type) <IL 0x000e8, 0x007fb>
12-22 15:32:17.710 I/MonoDroid(11013): at Java.Lang.Object._GetObject<Android.Views.ActionMode/ICallback> (intptr,Android.Runtime.JniHandleOwnership) <0x00107>
12-22 15:32:17.710 I/MonoDroid(11013): at Java.Lang.Object.GetObject<Android.Views.ActionMode/ICallback> (intptr,Android.Runtime.JniHandleOwnership) <0x0006f>
12-22 15:32:17.710 I/MonoDroid(11013): at Java.Lang.Object.GetObject<Android.Views.ActionMode/ICallback> (intptr,intptr,Android.Runtime.JniHandleOwnership) <0x0009b>
12-22 15:32:17.710 I/MonoDroid(11013): at Android.Views.ActionMode/ICallbackInvoker.n_OnDestroyActionMode_Landroid_view_ActionMode_ (intptr,intptr,intptr) <IL 0x00003, 0x00067>
12-22 15:32:17.710 I/MonoDroid(11013): at (wrapper dynamic-method) object.55335e29-aac6-42ae-beab-8588768f8022 (intptr,intptr,intptr) <IL 0x00017, 0x00043>
12-22 15:32:17.730 D/AndroidRuntime(11013): Shutting down VM
12-22 15:32:17.730 W/dalvikvm(11013): threadid=1: thread exiting with uncaught exception (group=0x41835c08)
An unhandled exception occured.


***************

12-22 15:47:18.358 I/MonoDroid(11742): UNHANDLED EXCEPTION:
12-22 15:47:18.369 I/MonoDroid(11742): System.ArgumentException: 'jobject' must not be IntPtr.Zero.
12-22 15:47:18.369 I/MonoDroid(11742): Parameter name: jobject
12-22 15:47:18.369 I/MonoDroid(11742): at Android.Runtime.JNIEnv.CallVoidMethod (intptr,intptr) <IL 0x0001f, 0x000c8>
12-22 15:47:18.369 I/MonoDroid(11742): at Android.Views.ActionModeInvoker.Finish () <IL 0x00038, 0x0013f>
12-22 15:47:18.369 I/MonoDroid(11742): at Xamarin.Forms.Platform.Android.CellAdapter.OnActionItemClicked (Android.Views.ActionMode,Android.Views.IMenuItem) <IL 0x00008, 0x00083>
12-22 15:47:18.369 I/MonoDroid(11742): at Android.Views.ActionMode/ICallbackInvoker.n_OnActionItemClicked_Landroid_view_ActionMode_Landroid_view_MenuItem_ (intptr,intptr,intptr,intptr) <IL 0x0001c, 0x00153>
12-22 15:47:18.369 I/MonoDroid(11742): at (wrapper dynamic-method) object.5a1d4136-f574-4dda-9c12-ad180133704b (intptr,intptr,intptr,intptr) <IL 0x0001d, 0x00053>
12-22 15:47:18.389 D/AndroidRuntime(11742): Shutting down VM
12-22 15:47:18.389 W/dalvikvm(11742): threadid=1: thread exiting with uncaught exception (group=0x41835c08)
An unhandled exception occured.

12-22 15:47:23.724 E/AndroidRuntime(11742): FATAL EXCEPTION: main
12-22 15:47:23.724 E/AndroidRuntime(11742): Process: MobilePlayPen2.Droid, PID: 11742
12-22 15:47:23.724 E/AndroidRuntime(11742): java.lang.RuntimeException: java.lang.reflect.InvocationTargetException
12-22 15:47:23.724 E/AndroidRuntime(11742): 	at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1099)
12-22 15:47:23.724 E/AndroidRuntime(11742): 	at dalvik.system.NativeStart.main(Native Method)
12-22 15:47:23.724 E/AndroidRuntime(11742): Caused by: java.lang.reflect.InvocationTargetException
12-22 15:47:23.724 E/AndroidRuntime(11742): 	at java.lang.reflect.Method.invokeNative(Native Method)
12-22 15:47:23.724 E/AndroidRuntime(11742): 	at java.lang.reflect.Method.invoke(Method.java:515)
12-22 15:47:23.724 E/AndroidRuntime(11742): 	at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1283)
12-22 15:47:23.724 E/AndroidRuntime(11742): 	... 2 more
12-22 15:47:23.724 E/AndroidRuntime(11742): Caused by: md52ce486a14f4bcd95899665e9d932190b.JavaProxyThrowable: System.ArgumentException: 'jobject' must not be IntPtr.Zero.
12-22 15:47:23.724 E/AndroidRuntime(11742): Parameter name: jobject
12-22 15:47:23.724 E/AndroidRuntime(11742): at Android.Runtime.JNIEnv.CallVoidMethod (intptr,intptr) <IL 0x0001f, 0x000c8>
12-22 15:47:23.724 E/AndroidRuntime(11742): at Android.Views.ActionModeInvoker.Finish () <IL 0x00038, 0x0013f>
12-22 15:47:23.724 E/AndroidRuntime(11742): at Xamarin.Forms.Platform.Android.CellAdapter.OnActionItemClicked (Android.Views.ActionMode,Android.Views.IMenuItem) <IL 0x00008, 0x00083>
12-22 15:47:23.724 E/AndroidRuntime(11742): at Android.Views.ActionMode/ICallbackInvoker.n_OnActionItemClicked_Landroid_view_ActionMode_Landroid_view_MenuItem_ (intptr,intptr,intptr,intptr) <IL 0x0001c, 0x00153>
12-22 15:47:23.724 E/AndroidRuntime(11742): at (wrapper dynamic-method) object.5a1d4136-f574-4dda-9c12-ad180133704b (intptr,intptr,intptr,intptr) <IL 0x0001d, 0x00053>
12-22 15:47:23.724 E/AndroidRuntime(11742): 
12-22 15:47:23.724 E/AndroidRuntime(11742): 	at md5282f1122c1313907b9bf274dd2c2f344.CellAdapter.n_onActionItemClicked(Native Method)
12-22 15:47:23.724 E/AndroidRuntime(11742): 	at md5282f1122c1313907b9bf274dd2c2f344.CellAdapter.onActionItemClicked(CellAdapter.java:56)
12-22 15:47:23.724 E/AndroidRuntime(11742): 	at com.android.internal.policy.impl.PhoneWindow$DecorView$ActionModeCallbackWrapper.onActionItemClicked(PhoneWindow.java:3029)
12-22 15:47:23.724 E/AndroidRuntime(11742): 	at com.android.internal.app.ActionBarImpl$ActionModeImpl.onMenuItemSelected(ActionBarImpl.java:1081)
12-22 15:47:23.724 E/AndroidRuntime(11742): 	at com.android.internal.view.menu.MenuBuilder.dispatchMenuItemSelected(MenuBuilder.java:735)
12-22 15:47:23.724 E/AndroidRuntime(11742): 	at com.android.internal.view.menu.MenuItemImpl.invoke(MenuItemImpl.java:152)
12-22 15:47:23.724 E/AndroidRuntime(11742): 	at com.android.internal.view.menu.MenuBuilder.performItemAction(MenuBuilder.java:874)
12-22 15:47:23.724 E/AndroidRuntime(11742): 	at com.android.internal.view.menu.ActionMenuView.invokeItem(ActionMenuView.java:645)
12-22 15:47:23.724 E/AndroidRuntime(11742): 	at com.android.internal.view.menu.ActionMenuItemView.onClick(ActionMenuItemView.java:211)
12-22 15:47:23.724 E/AndroidRuntime(11742): 	at android.view.View.performClick(View.java:4640)
12-22 15:47:23.724 E/AndroidRuntime(11742): 	at android.view.View$PerformClick.run(View.java:19431)
12-22 15:47:23.724 E/AndroidRuntime(11742): 	at android.os.Handler.handleCallback(Handler.java:733)
12-22 15:47:23.724 E/AndroidRuntime(11742): 	at android.os.Handler.dispatchMessage(Handler.java:95)
12-22 15:47:23.724 E/AndroidRuntime(11742): 	at android.os.Looper.loop(Looper.java:146)
12-22 15:47:23.724 E/AndroidRuntime(11742): 	at android.app.ActivityThread.main(ActivityThread.java:5598)
12-22 15:47:23.724 E/AndroidRuntime(11742): 	... 5 more
Comment 1 Parmendra Kumar 2016-01-14 14:09:34 UTC
Created attachment 14584 [details]
Sample Project

I have tried to reproduce this issue and observed that after apply all three attached file I a getting error on "CarbonObservableCollection<string>"

Screencast: http://www.screencast.com/t/6s11ZGkcG

I have also attached the sample project.

Please follow the sample project and let me know if I have missed anything.

Thanks.
Comment 2 Paul Charlton 2016-01-14 14:17:28 UTC
Created attachment 14585 [details]
sample files, fixed collection issue
Comment 3 Paul Charlton 2016-01-14 14:18:09 UTC
Apologies, i've fixed my sample files, but CarbonObservableCollection can be changed to ObservableCOllection
Comment 4 Parmendra Kumar 2016-01-15 16:12:13 UTC
@Paul,

I have used code attached in comment #2 but I am still getting a run time exception.

Screencast: http://www.screencast.com/t/dgEmMgztfx

DebugLog: https://gist.github.com/Parmendrak/9090c878b85e3b0b4b31

Could you Please provide me a sample project? so that I can reproduce this issue.
Comment 5 Paul Charlton 2016-01-18 11:03:52 UTC
Created attachment 14615 [details]
Full sample project

Again apologies, full sample attached (probably should have done this in the first place...)
Comment 6 Parmendra Kumar 2016-02-09 11:43:55 UTC
I have checked this issue and able to reproduce it. To reproduce this issue I have followed following steps:

1. Open attached sample in VS (attached in comment #5).
2. Deploy to Android/Emulator.
3. Long press to display list item. 
4. Select the "Error Me" option.

Screencast: http://www.screencast.com/t/mFBYSefAEqrl

DebugLog:https://gist.github.com/Parmendrak/6a3c290ab8e77d35fdc4

Environment Info:

Microsoft Visual Studio Enterprise 2015
Version 14.0.24720.00 Update 1
Microsoft .NET Framework
Version 4.6.01055

Installed Version: Enterprise

Xamarin   4.0.1.93 (c7ebc0f)
Visual Studio extension to enable development for Xamarin.iOS and Xamarin.Android.

Xamarin.Android   6.0.1.10 (e98e962)
Visual Studio plugin to enable development for Xamarin.Android.

Xamarin.iOS   9.4.1.24 (47eb74b)
Visual Studio extension to enable development for Xamarin.iOS.
Comment 7 David Ortinau [MSFT] 2017-09-07 13:12:33 UTC
Confirmed this occurs in 2.4.0.269-pre2. Seems similar to #56274