This is Xamarin's bug tracking system. For product support, please use the support links listed in your Xamarin Account.
Bug 42678 - [Android] System.ObjectDisposedException when tapping a toolbar button after switching tabs.
Summary: [Android] System.ObjectDisposedException when tapping a toolbar button after ...
Status: RESOLVED FIXED
Alias: None
Product: Forms
Classification: Xamarin
Component: Android (show other bugs)
Version: 2.3.0
Hardware: Macintosh Mac OS
: --- normal
Target Milestone: ---
Assignee: Bugzilla
URL:
Depends on:
Blocks:
 
Reported: 2016-07-19 21:46 UTC by Jon Goldberger
Modified: 2017-06-09 15:49 UTC (History)
36 users (show)

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


Attachments
Crash report (7.48 KB, text/plain)
2016-12-08 12:24 UTC, gareth.wynn
Details

Description Jon Goldberger 2016-07-19 21:46:01 UTC
## Description

When tapping a toolbar item on the first page of a tabbed page after having opened other pages in the tabbed page results in a System.ObjectDisposedException. Android only, works as expected on iOS. 

Stack Trace:
>System.ObjectDisposedException: Cannot access a disposed object.
>Object name: 'Xamarin.Forms.Platform.Android.AppCompat.NavigationPageRenderer'.
>  at Java.Interop.JniPeerMembers.AssertSelf (IJavaPeerable self) [0x00030] in /Users/builder/data/lanes/3415/7db2aac3/source/Java.Interop/src/Java.Interop/Java.Interop/JniPeerMembers.cs:153
>  at Java.Interop.JniPeerMembers+JniInstanceMethods.InvokeNonvirtualObjectMethod (System.String encodedMember, IJavaPeerable self, Java.Interop.JniArgumentValue* parameters) [0x00002] in /Users/builder/data/lanes/3415/7db2aac3/source/Java.Interop/src/Java.Interop/Java.Interop/JniPeerMembers.JniInstanceMethods_Invoke.cs:361
>  at Android.Views.View.get_Context () [0x00000] in /Users/builder/data/lanes/3415/7db2aac3/source/monodroid/src/Mono.Android/platforms/android-23/src/generated/Android.Views.View.cs:4687
>  at Xamarin.Forms.Platform.Android.AppCompat.NavigationPageRenderer.UpdateMenu () [0x00006] in C:\BuildAgent\work\aad494dc9bc9783\Xamarin.Forms.Platform.Android\AppCompat\NavigationPageRenderer.cs:637
>  at Xamarin.Forms.Platform.Android.AppCompat.NavigationPageRenderer.HandleToolbarItemPropertyChanged (System.Object sender, System.ComponentModel.PropertyChangedEventArgs e) [0x00045] in C:\BuildAgent\work\aad494dc9bc9783\Xamarin.Forms.Platform.Android\AppCompat\NavigationPageRenderer.cs:381
>  at at (wrapper delegate-invoke) <Module>:invoke_void_object_PropertyChangedEventArgs (object,System.ComponentModel.PropertyChangedEventArgs)
>  at Xamarin.Forms.BindableObject.OnPropertyChanged (System.String propertyName) [0x0000a] in C:\BuildAgent\work\aad494dc9bc9783\Xamarin.Forms.Core\BindableObject.cs:137
>  at Xamarin.Forms.Element.OnPropertyChanged (System.String propertyName) [0x00000] in C:\BuildAgent\work\aad494dc9bc9783\Xamarin.Forms.Core\Element.cs:370
>  at Xamarin.Forms.BindableObject.SetValueActual (Xamarin.Forms.BindableProperty property, Xamarin.Forms.BindablePropertyContext context, System.Object value, Boolean currentlyApplying, SetValueFlags attributes, Boolean silent) [0x000f4] in C:\BuildAgent\work\aad494dc9bc9783\Xamarin.Forms.Core\BindableObject.cs:581
>  at Xamarin.Forms.BindableObject.SetValueCore (Xamarin.Forms.BindableProperty property, System.Object value, SetValueFlags attributes, SetValuePrivateFlags privateAttributes) [0x0014b] in C:\BuildAgent\work\aad494dc9bc9783\Xamarin.Forms.Core\BindableObject.cs:378
>  at Xamarin.Forms.BindingExpression.ApplyCore (System.Object sourceObject, Xamarin.Forms.BindableObject target, Xamarin.Forms.BindableProperty property, Boolean fromTarget) [0x0020c] in C:\BuildAgent\work\aad494dc9bc9783\Xamarin.Forms.Core\BindingExpression.cs:177
>  at Xamarin.Forms.BindingExpression.Apply (Boolean fromTarget) [0x0003e] in C:\BuildAgent\work\aad494dc9bc9783\Xamarin.Forms.Core\BindingExpression.cs:55
>  at Xamarin.Forms.BindingExpression+BindingExpressionPart.<PropertyChanged>b__44_0 () [0x00000] in C:\BuildAgent\work\aad494dc9bc9783\Xamarin.Forms.Core\BindingExpression.cs:475
>  at Java.Lang.Thread+RunnableImplementor.Run () [0x0000b] in /Users/builder/data/lanes/3415/7db2aac3/source/monodroid/src/Mono.Android/src/Java.Lang/Thread.cs:36
>  at Java.Lang.IRunnableInvoker.n_Run (IntPtr jnienv, IntPtr native__this) [0x00009] in /Users/builder/data/lanes/3415/7db2aac3/source/monodroid/src/Mono.Android/platforms/android-23/src/generated/Java.Lang.IRunnable.cs:81
>  at at (wrapper dynamic-method) System.Object:bc0fff07-f8bd-4289-8c6b-510f4045e0d2 (intptr,intptr)
>

This was brought up in a forum thread and also a desk case that just came in. Forum thread:
https://forums.xamarin.com/discussion/66566/cannot-access-a-disposed-object-appcompat-navigationpagerenderer

## Steps to reproduce:

1. Download the sample noted in the above forum thread:
https://github.com/codemillmatt/droidcrash

2. Deploy to Android device or simulator (Tested with XAP Nexus 5 Lollipop)

3. Select "SECOND" tab.

4. Select "FIRST" tab

5. Click on either the "FIRST" or "SECOND" toolbar button (above the tab bar)

Expected result: no exception thrown or crash.

Actual result: App crashes with the above stack trace. 

## Notes

Tested with the following Forms versions with the same results on all:
2.2.0.31
2.3.0.107
2.3.1.111-pre2


## Environment

=== Xamarin Studio Enterprise ===

Version 6.0.1 (build 9)
Installation UUID: ceaba76c-db06-4fbd-b326-f69ea53c3e01
Runtime:
	Mono 4.4.1 (mono-4.4.0-branch-c7sr0/4747417) (64-bit)
	GTK+ 2.24.23 (Raleigh theme)

	Package version: 404010000

=== Xamarin.Profiler ===

Version: 0.33.1
Location: /Applications/Xamarin Profiler.app/Contents/MacOS/Xamarin Profiler

=== Apple Developer Tools ===

Xcode 7.3.1 (10188.1)
Build 7D1014

=== Xamarin.Android ===

Version: 6.1.1.1 (Visual Studio Enterprise)
Android SDK: /Users/jongoldberger/Library/Developer/Xamarin/android-sdk-macosx
	Supported Android versions:
		4.0.3 (API level 15)
		4.1   (API level 16)
		4.2   (API level 17)
		4.3   (API level 18)
		4.4   (API level 19)
		5.0   (API level 21)
		5.1   (API level 22)
		6.0   (API level 23)

SDK Tools Version: 25.1.7
SDK Platform Tools Version: 23.1
SDK Build Tools Version: 23.0.3

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

Android Designer EPL code available here:
https://github.com/xamarin/AndroidDesigner.EPL

=== Xamarin Android Player ===

Version: 0.6.5
Location: /Applications/Xamarin Android Player.app

=== Xamarin.Mac ===

Version: 2.8.1.4 (Visual Studio Enterprise)

=== Xamarin.iOS ===

Version: 9.8.1.4 (Visual Studio Enterprise)
Hash: 3cf8aae
Branch: c7sr0
Build date: 2016-06-20 16:09:58-0400

=== Xamarin Inspector ===

Version: 0.8.0.0
Hash: dc081aa
Branch: master
Build date: Tue Apr 26 23:07:44 UTC 2016

=== Build Information ===

Release ID: 600010009
Git revision: e879ce52093257c5c386ad7e390dfaa937fa7f90
Build date: 2016-06-24 11:53:43-04
Xamarin addins: a9252e6df4851fbbed1f9c6228e7b6dd1b475ac5
Build lane: monodevelop-lion-cycle7-sr0

=== Operating System ===

Mac OS X 10.11.5
Darwin Jons-MacBook-Pro.local 15.5.0 Darwin Kernel Version 15.5.0
    Tue Apr 19 18:36:36 PDT 2016
    root:xnu-3248.50.21~8/RELEASE_X86_64 x86_64

=== Enabled user installed addins ===

Xamarin Inspector 0.8.0.0
Comment 3 Karl 2016-08-25 04:27:32 UTC
Getting this as well when opening a new screen from a tabbed screen, then closing the newly opened screen:

Cannot access a disposed object. Object name: 'Xamarin.Forms.Platform.Android.EntryEditText'.
Comment 4 eugine.krupin 2016-08-26 08:03:10 UTC
Similar problem here. I have grid view in Xamarin.Android application and when i open new activity and come back to previous activity, sometimes during scroll or touch to grid view items i have "System.ObjectDisposedException, object name: Android.View.GestureDetector" that unable to catch, it just crash an application.
Comment 5 Jani Lirkki 2016-09-14 14:18:20 UTC
Still reproducible on latest Xamarin Forms version 2.3.2.127. The steps to reproduce are:
1) Start the attached sample app.
2) Choose SECOND tab.
3) Choose THIRD tab.
4) Choose FIRST tab.
5) Choose FIRST toolbar item.
 --> Crash
Comment 6 dj_technohead 2016-09-15 00:08:33 UTC
I am experiencing the same problem with Xamarin Android, but in a non-Xamarin Forms application, with a bottom navigation bar switching between different fragments on an activity:

"  at Java.Interop.JniPeerMembers.AssertSelf (IJavaPeerable self) [0x00030] in /Users/builder/data/lanes/3540/1cf254db/source/Java.Interop/src/Java.Interop/Java.Interop/JniPeerMembers.cs:153 \n  at Java.Interop.JniPeerMembers+JniInstanceMethods.InvokeVirtualObjectMethod (System.String encodedMember, IJavaPeerable self, Java.Interop.JniArgumentValue* parameters) [0x00002] in /Users/builder/data/lanes/3540/1cf254db/source/Java.Interop/src/Java.Interop/Java.Interop/JniPeerMembers.JniInstanceMethods_Invoke.cs:345 \n  at Android.App.Activity.get_FragmentManager () [0x00000] in /Users/builder/data/lanes/3540/1cf254db/source/monodroid/src/Mono.Android/platforms/android-23/src/generated/Android.App.Activity.cs:399 \n  at Stringify.Client.Common.Droid.SClientCommonDroidActivity.pushFragmentWithAnimation (System.String fragmentType, Boolean switchIfAlreadyExists, Int32 enterAnim, Int32 exitAnim, Boolean addBackStack) [0x0000c] in /Users/dennis/Documents/Projects/CrossPlatform/Stringify.Client.Common.Droid/Custom/SClientCommonDroidActivity.cs:488 "
Comment 7 Kent 2016-09-15 02:31:42 UTC
Just came to add my voice too. For me, the repro is:

1. Start app.
2. Hit back button (app closes)
3. Hit history button and select app again (app is foregrounded)
4. Tap toolbar item

My toolbar item switches between two images when you tap it. But the same problem presents itself if the toolbar item attempts to disable itself, for example.
Comment 8 eugine.krupin 2016-09-15 08:22:23 UTC
In my case I found a true reason of this exception: GestureDetector was disposed in layout inside of cells, e.g Grid, that you can touch. And it causes exception.
Comment 9 Jani Lirkki 2016-09-19 07:08:35 UTC
I am no longer able to reproduce this with Xamarin Forms version 2.3.3.152-pre2.
Comment 10 Rui Marinho 2016-09-19 11:30:24 UTC
Jon can you confirm if this is fixed in 2.3.3-pre2 ?
Comment 11 Jon Goldberger 2016-09-19 19:09:40 UTC
@rui,

I tested using the steps to reproduce in the bug description and I can no longer reproduce the issue. The actual result is as expected.

I will leave it to you to set the status accordingly.
Comment 12 wilhelm 2016-09-27 08:26:42 UTC
I have a similar problem resulting in this crashreport:

JniPeerMembers.AssertSelf
    android.runtime.JavaProxyThrowable: System.ObjectDisposedException: Cannot access a disposed object.

    Xamarin caused by: android.runtime.JavaProxyThrowable: System.ObjectDisposedException: Cannot access a disposed object.
    Object name: 'Android.Views.GestureDetector'.
      at Java.Interop.JniPeerMembers.AssertSelf (Java.Interop.IJavaPeerable self) [0x00030] in <1ffd3ccbc0a94ef7ae196a00f15726c5>:0 
      at Java.Interop.JniPeerMembers+JniInstanceMethods.InvokeVirtualBooleanMethod (System.String encodedMember, Java.Interop.IJavaPeerable self, Java.Interop.JniArgumentValue* parameters) [0x00001] in <1ffd3ccbc0a94ef7ae196a00f15726c5>:0 
      at Android.Views.GestureDetector.OnTouchEvent (Android.Views.MotionEvent ev) [0x00036] in <b43d52659f264524949550a88970d88c>:0 
      at Xamarin.Forms.Platform.Android.VisualElementRenderer`1[TElement].Android.Views.View.IOnTouchListener.OnTouch (Android.Views.View v, Android.Views.MotionEvent e) [0x0004a] in <cd4dd8cd6c10471eac2e6a585cf564ae>:0 
      at Android.Views.View+IOnTouchListenerInvoker.n_OnTouch_Landroid_view_View_Landroid_view_MotionEvent_ (System.IntPtr jnienv, System.IntPtr native__this, System.IntPtr native_v, System.IntPtr native_e) [0x00019] in <b43d52659f264524949550a88970d88c>:0 
      at (wrapper dynamic-method) System.Object:3e3eab80-2e2d-4a8b-a575-8781330f4b54 (intptr,intptr,intptr,intptr)
        at md5b60ffeb829f638581ab2bb9b1a7f4f3f.VisualElementRenderer_1.n_onTouch(Native Method)
        at md5b60ffeb829f638581ab2bb9b1a7f4f3f.VisualElementRenderer_1.onTouch(VisualElementRenderer_1.java:57)
        at android.view.View.dispatchTouchEvent(View.java:8802)
        at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2569)
        at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2239)


Updating to 2.3.3.152-pre2 does not fix this for me.
Comment 13 abel_vilalta 2016-10-11 12:20:55 UTC
Hi people,

Same error for me...Very annoying...Should be fixed...On my case this was always happening on a ListView... The only way I found to solve it after a lot of time is using ListViewCachingStrategy to RecycleElement...

System.ObjectDisposedException: Cannot access a disposed object.
Object name: 'Android.Views.GestureDetector'.
  at at (wrapper managed-to-native) Java.Interop.NativeMethods:java_interop_jnienv_call_nonvirtual_boolean_method_a (intptr,intptr&,intptr,intptr,intptr,Java.Interop.JniArgumentValue*)
  at Java.Interop.JniEnvironment+InstanceMethods.CallNonvirtualBooleanMethod (Java.Interop.JniObjectReference instance, Java.Interop.JniObjectReference type, Java.Interop.JniMethodInfo method, Java.Interop.JniArgumentValue* args) [0x0008f] in /Users/builder/data/lanes/3819/96c7ba6c/source/Java.Interop/src/Java.Interop/Java.Interop/JniEnvironment.g.cs:11728
  at Java.Interop.JniPeerMembers+JniInstanceMethods.InvokeVirtualBooleanMethod (System.String encodedMember, Java.Interop.IJavaPeerable self, Java.Interop.JniArgumentValue* parameters) [0x0006b] in /Users/builder/data/lanes/3819/96c7ba6c/source/Java.Interop/src/Java.Interop/Java.Interop/JniPeerMembers.JniInstanceMethods_Invoke.cs:67
  at Android.Views.View.DispatchTouchEvent (Android.Views.MotionEvent e) [0x0002c] in /Users/builder/data/lanes/3819/96c7ba6c/source/monodroid/src/Mono.Android/platforms/android-23/src/generated/Android.Views.View.cs:12433
  at Xamarin.Forms.Platform.Android.PlatformRenderer.DispatchTouchEvent (Android.Views.MotionEvent e) [0x00035] in C:\BuildAgent2\work\aad494dc9bc9783\Xamarin.Forms.Platform.Android\PlatformRenderer.cs:32
  at Android.Views.View.n_DispatchTouchEvent_Landroid_view_MotionEvent_ (System.IntPtr jnienv, System.IntPtr native__this, System.IntPtr native_e) [0x00011] in /Users/builder/data/lanes/3819/96c7ba6c/source/monodroid/src/Mono.Android/platforms/android-23/src/generated/Android.Views.View.cs:12420
  at at (wrapper dynamic-method) System.Object:c598aa16-616f-467c-8c9c-b297525de4c4 (intptr,intptr,intptr)

I don't know if for you Xamarin guys can help you...

Cheers
Comment 14 Pete Schmitz 2016-10-15 20:02:27 UTC
We were broadsided with this exception over the weekend - causing a crash on our production build that affected 100 people. I attempted to publish a patch that included a forms update to 2.3.3-pre2, but the exception still occurs.

Xamarin Studio Community: 6.1.1 (Mac OS X 10.11.6)
Xamarin.Android: 7.0.1.3
Xamarin Forms: 2.3.0 & 2.3.3.152-pre2

Stack:
System.ObjectDisposedException
Cannot access a disposed object. Object name: 'Android.Views.GestureDetector'.
Raw
Java.Interop.JniPeerMembers.AssertSelf(IJavaPeerable self)<9aec6cf6979740dc91bab8e1d1654250>:0
Java.Interop.JniPeerMembers.JniInstanceMethods.InvokeVirtualBooleanMethod(string encodedMember, IJavaPeerable self, JniArgumentValue* parameters)<9aec6cf6979740dc91bab8e1d1654250>:0
Android.Views.GestureDetector.OnTouchEvent(MotionEvent ev)<f4b8c3b211b54d589c364a3a46c20109>:0
Xamarin.Forms.Platform.Android.VisualElementRenderer<TElement>.OnTouch(View v, MotionEvent e)<6f89f957685149c2a25984bfb0bd3bcb>:0
Android.Views.View.IOnTouchListenerInvoker.n_OnTouch_Landroid_view_View_Landroid_view_MotionEvent_(IntPtr jnienv, IntPtr native__this, IntPtr native_v, IntPtr native_e)<f4b8c3b211b54d589c364a3a46c20109>:0

What's particularly curious is that this exception started being thrown on a minor patch that included no forms update from a stable version of our app where this exception hadn't been occurring.

Now I'm attempting to downgrade Xamarin Android; will report back.
Comment 15 Pete Schmitz 2016-10-16 19:43:19 UTC
I can confirm that rolling back to Xamarin Android Version: 6.1.2.21 has prevented recurrences of the above exception on our binaries for both Forms 2.3.3.152-pre2 AND 2.3.0.

Our current production build is compiled with 6.1 and forms 2.3.0. If for some reason this exception pops up again I'll post an update.
Comment 16 Giusepe Casagrande 2016-10-25 16:26:59 UTC
Same problem here when going back and forward on a listView -> Detail

Xamarin Studio Community
Version 6.1.1 (build 15)
Installation UUID: 6d7f9291-aad8-4a9d-933b-26af792e3ad4
Runtime:
	Mono 4.6.1 (mono-4.6.0-branch-c8sr0/ef43c15) (64-bit)
	GTK+ 2.24.23 (Raleigh theme)

	Package version: 406010005

NuGet
Version: 3.4.3.0

Xamarin.Profiler
Version: 0.33.2
Location: /Applications/Xamarin Profiler.app/Contents/MacOS/Xamarin Profiler

Xamarin.Android
Version: 7.0.1.3 (Xamarin Studio Community)
Android SDK: /Users/giusepecasagrande/Library/Developer/Xamarin/android-sdk-macosx
	Supported Android versions:
		4.4 (API level 19)
		6.0 (API level 23)
		7.0 (API level 24)

SDK Tools Version: 25.2.2
SDK Platform Tools Version: 24.0.3
SDK Build Tools Version: 24.0.2

Java SDK: /usr
java version "1.8.0_25"
Java(TM) SE Runtime Environment (build 1.8.0_25-b17)
Java HotSpot(TM) 64-Bit Server VM (build 25.25-b02, mixed mode)

Android Designer EPL code available here:
https://github.com/xamarin/AndroidDesigner.EPL

Xamarin Android Player
Not Installed

Apple Developer Tools
Xcode 8.0 (11246)
Build 8A218a

Xamarin.Mac
Version: 2.10.0.105 (Xamarin Studio Community)

Xamarin.iOS
Version: 10.0.1.10 (Xamarin Studio Community)
Hash: ad1cd42
Branch: cycle8-sr0-xi
Build date: 2016-10-03 15:18:44-0400

Xamarin Inspector
Version: 0.8.0.0
Hash: dc081aa
Branch: master
Build date: Tue Apr 26 23:07:44 UTC 2016

Build Information
Release ID: 601010015
Git revision: fa52f02641726146e2589ed86ec4097fbe101888
Build date: 2016-09-22 08:03:02-04
Xamarin addins: 75d65712af93d54dc39ae4c42b21dfa574859fd6
Build lane: monodevelop-lion-cycle8-sr0

Operating System
Mac OS X 10.12.0
Darwin JARVIS 16.0.0 Darwin Kernel Version 16.0.0
    Mon Aug 29 17:56:20 PDT 2016
    root:xnu-3789.1.32~3/RELEASE_X86_64 x86_64

Enabled user installed addins
Xamarin Inspector 0.8.0.0
Comment 17 Chris 2016-11-22 10:38:57 UTC
I'm seeing this bug occasionally in a non Xamarin Forms Android project with a GestureDetector, when a second Activity covers it and then displays a Dialog.

This seems to be causing it to be disposed even though it's readonly and the Activity that created it is still in the back stack.

I've only been experiencing this issue since updating to the most recent release of Xamarin and the various support libraries.
Comment 18 Robert Ewen 2016-11-23 20:33:15 UTC
We are getting same exception while making a touch on a listview.
It only happens after the GC has done his job. for some reason, GC thinks he can remove a GestureDetector ...

Xamarin.Forms 2.3.3.168 (happend with 2.3.0.49 too)

The App is unusable, because we can not get around this crash ...

I/MonoDroid( 3501): UNHANDLED EXCEPTION:
I/MonoDroid( 3501): System.ObjectDisposedException: Cannot access a disposed object.
I/MonoDroid( 3501): Object name: 'Android.Views.GestureDetector'.
I/MonoDroid( 3501):   at(wrapper managed-to-native) Java.Interop.NativeMethods:java_interop_jnienv_call_nonvirtual_boolean_method_a(intptr, intptr&, intptr, intptr, intptr, Java.Interop.JniArgumentValue*)
I/MonoDroid( 3501):   at Java.Interop.JniEnvironment+InstanceMethods.CallNonvirtualBooleanMethod (Java.Interop.JniObjectReference instance, Java.Interop.JniObjectReference type, Java.Interop.JniMethodInfo method, Java.Interop.JniArgumentValue* args) [0x0008f] in /Users/builder/data/lanes/3511/ce955cc0/source/Java.Interop/src/Java.Interop/Java.Interop/JniEnvironment.g.cs:11728 
I/MonoDroid( 3501):   at Java.Interop.JniPeerMembers+JniInstanceMethods.InvokeVirtualBooleanMethod (System.String encodedMember, Java.Interop.IJavaPeerable self, Java.Interop.JniArgumentValue* parameters) [0x0006b] in /Users/builder/data/lanes/3511/ce955cc0/source/Java.Interop/src/Java.Interop/Java.Interop/JniPeerMembers.JniInstanceMethods_Invoke.cs:67 
I/MonoDroid( 3501):   at Android.Views.View.DispatchTouchEvent(Android.Views.MotionEvent e) [0x0002c] in /Users/builder/data/lanes/3511/ce955cc0/source/monodroid/src/Mono.Android/platforms/android-24/src/generated/Android.Views.View.cs:12619 
I/MonoDroid( 3501):   at Xamarin.Forms.Platform.Android.PlatformRenderer.DispatchTouchEvent(Android.Views.MotionEvent e) [0x00035] in C:\BuildAgent2\work\ca3766cfc22354a1\Xamarin.Forms.Platform.Android\PlatformRenderer.cs:32 
I/MonoDroid( 3501):   at Android.Views.View.n_DispatchTouchEvent_Landroid_view_MotionEvent_(System.IntPtr jnienv, System.IntPtr native__this, System.IntPtr native_e) [0x00011] in /Users/builder/data/lanes/3511/ce955cc0/source/monodroid/src/Mono.Android/platforms/android-24/src/generated/Android.Views.View.cs:12606 
I/MonoDroid( 3501):   at(wrapper dynamic-method) System.Object:1d6ccd67-ae5f-4fd0-9e86-7a2026992447(intptr, intptr, intptr)
E/mono-rt( 3501): Stacktrace:
E/mono-rt( 3501): 
E/mono-rt( 3501):   at<unknown> <0xffffffff>
E/mono-rt( 3501):   at(wrapper managed-to-native) Java.Interop.NativeMethods.java_interop_jnienv_new_string (intptr,intptr&,char*,int) <0x00047>
E/mono-rt( 3501):   at Java.Interop.JniEnvironment/Strings.NewString (char*, int) [0x0000a] in /Users/builder/data/lanes/3511/ce955cc0/source/Java.Interop/src/Java.Interop/Java.Interop/JniEnvironment.g.cs:13019
E/mono-rt( 3501):   at Java.Interop.JniEnvironment/Strings.NewString (string) [0x00028] in /Users/builder/data/lanes/3511/ce955cc0/source/Java.Interop/src/Java.Interop/Java.Interop/JniEnvironment.Strings.cs:15
E/mono-rt( 3501):   at Android.Runtime.JNIEnv.NewString(string) [0x0000c] in /Users/builder/data/lanes/3511/ce955cc0/source/xamarin-android/src/Mono.Android/Android.Runtime/JNIEnv.cs:937
E/mono-rt( 3501):   at Java.Lang.Throwable..ctor(string) [0x00022] in /Users/builder/data/lanes/3511/ce955cc0/source/monodroid/src/Mono.Android/platforms/android-24/src/generated/Java.Lang.Throwable.cs:47
E/mono-rt( 3501):   at Android.Runtime.JavaProxyThrowable..ctor(System.Exception) [0x00000] in /Users/builder/data/lanes/3511/ce955cc0/source/xamarin-android/src/Mono.Android/Android.Runtime/JavaProxyThrowable.cs:10
E/mono-rt( 3501):   at Java.Lang.Throwable.FromException(System.Exception) [0x00023] in /Users/builder/data/lanes/3511/ce955cc0/source/xamarin-android/src/Mono.Android/Java.Lang/Throwable.cs:241
E/mono-rt( 3501):   at Android.Runtime.AndroidEnvironment.UnhandledException(System.Exception) [0x0007e] in /Users/builder/data/lanes/3511/ce955cc0/source/xamarin-android/src/Mono.Android/Android.Runtime/AndroidEnvironment.cs:116
E/mono-rt( 3501):   at(wrapper dynamic-method) object.1d6ccd67-ae5f-4fd0-9e86-7a2026992447(intptr, intptr, intptr) <IL 0x00030, 0x0009f>
E/mono-rt( 3501):   at(wrapper native-to-managed) object.1d6ccd67-ae5f-4fd0-9e86-7a2026992447(intptr, intptr, intptr) <IL 0x00023, 0x000ff>
Comment 19 adrianknight89 2016-12-05 00:51:32 UTC
I also cannot reproduce this. I tested it on latest master.
Comment 20 gareth.wynn 2016-12-08 12:24:47 UTC
Created attachment 18826 [details]
Crash report

Crash report from android app built against Xamarin Forms 2.3.1.114, seen on droid versions 6.0.1 and 7.1.
Comment 21 Morten 2016-12-21 06:58:31 UTC
Still crashes with Xamarin Forms 2.3.3.175 and preventing me from publishing a new App, unless I soon find a usable workaround.
Comment 22 E.Z. Hart 2017-01-31 21:59:42 UTC
(In reply to eugine.krupin from comment #8)
> In my case I found a true reason of this exception: GestureDetector was
> disposed in layout inside of cells, e.g Grid, that you can touch. And it
> causes exception.

Eugine,

The stacktrace from the originally reported exception does not include GestureDetector, and the repro project does not include any controls which use cells. I suspect you're seeing a different bug than originally posted. 

If you're still seeing this problem with the latest version of Xamarin Forms, please open a new Bugzilla issue for it.
Comment 24 E.Z. Hart 2017-01-31 22:07:55 UTC
(In reply to wilhelm from comment #12)
> I have a similar problem resulting in this crashreport:
> 
> JniPeerMembers.AssertSelf
>     android.runtime.JavaProxyThrowable: System.ObjectDisposedException:
> Cannot access a disposed object.
> 
>     Xamarin caused by: android.runtime.JavaProxyThrowable:
> System.ObjectDisposedException: Cannot access a disposed object.
>     Object name: 'Android.Views.GestureDetector'.
>       at Java.Interop.JniPeerMembers.AssertSelf (Java.Interop.IJavaPeerable
> self) [0x00030] in <1ffd3ccbc0a94ef7ae196a00f15726c5>:0 
>       at
> Java.Interop.JniPeerMembers+JniInstanceMethods.InvokeVirtualBooleanMethod
> (System.String encodedMember, Java.Interop.IJavaPeerable self,
> Java.Interop.JniArgumentValue* parameters) [0x00001] in
> <1ffd3ccbc0a94ef7ae196a00f15726c5>:0 
>       at Android.Views.GestureDetector.OnTouchEvent
> (Android.Views.MotionEvent ev) [0x00036] in
> <b43d52659f264524949550a88970d88c>:0 
>       at
> Xamarin.Forms.Platform.Android.VisualElementRenderer`1[TElement].Android.
> Views.View.IOnTouchListener.OnTouch (Android.Views.View v,
> Android.Views.MotionEvent e) [0x0004a] in
> <cd4dd8cd6c10471eac2e6a585cf564ae>:0 
>       at
> Android.Views.View+IOnTouchListenerInvoker.
> n_OnTouch_Landroid_view_View_Landroid_view_MotionEvent_ (System.IntPtr
> jnienv, System.IntPtr native__this, System.IntPtr native_v, System.IntPtr
> native_e) [0x00019] in <b43d52659f264524949550a88970d88c>:0 
>       at (wrapper dynamic-method)
> System.Object:3e3eab80-2e2d-4a8b-a575-8781330f4b54
> (intptr,intptr,intptr,intptr)
>         at
> md5b60ffeb829f638581ab2bb9b1a7f4f3f.VisualElementRenderer_1.n_onTouch(Native
> Method)
>         at
> md5b60ffeb829f638581ab2bb9b1a7f4f3f.VisualElementRenderer_1.
> onTouch(VisualElementRenderer_1.java:57)
>         at android.view.View.dispatchTouchEvent(View.java:8802)
>         at
> android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2569)
>         at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2239)
> 
> 
> Updating to 2.3.3.152-pre2 does not fix this for me.

Wilhelm,

Based on that crash report, I believe you're seeing a different issue than the one originally reported. If you're still seeing this problem in the latest version of Xamarin Forms, please open a new Bugzilla issue for it.
Comment 26 E.Z. Hart 2017-01-31 22:13:33 UTC
(In reply to gareth.wynn from comment #20)
> Created attachment 18826 [details]
> Crash report
> 
> Crash report from android app built against Xamarin Forms 2.3.1.114, seen on
> droid versions 6.0.1 and 7.1.

Gareth,

Based on your attached crash report, it looks like you're seeing a different issue than the one originally reported. If you're still seeing this problem with the latest version of Xamarin Forms, please open a separate issue in Bugzilla.
Comment 27 E.Z. Hart 2017-01-31 22:15:28 UTC
(In reply to abel_vilalta from comment #13)
> Hi people,
> 
> Same error for me...Very annoying...Should be fixed...On my case this was
> always happening on a ListView... The only way I found to solve it after a
> lot of time is using ListViewCachingStrategy to RecycleElement...
> 
> System.ObjectDisposedException: Cannot access a disposed object.
> Object name: 'Android.Views.GestureDetector'.
>   at at (wrapper managed-to-native)
> Java.Interop.NativeMethods:
> java_interop_jnienv_call_nonvirtual_boolean_method_a
> (intptr,intptr&,intptr,intptr,intptr,Java.Interop.JniArgumentValue*)
>   at Java.Interop.JniEnvironment+InstanceMethods.CallNonvirtualBooleanMethod
> (Java.Interop.JniObjectReference instance, Java.Interop.JniObjectReference
> type, Java.Interop.JniMethodInfo method, Java.Interop.JniArgumentValue*
> args) [0x0008f] in
> /Users/builder/data/lanes/3819/96c7ba6c/source/Java.Interop/src/Java.Interop/
> Java.Interop/JniEnvironment.g.cs:11728
>   at
> Java.Interop.JniPeerMembers+JniInstanceMethods.InvokeVirtualBooleanMethod
> (System.String encodedMember, Java.Interop.IJavaPeerable self,
> Java.Interop.JniArgumentValue* parameters) [0x0006b] in
> /Users/builder/data/lanes/3819/96c7ba6c/source/Java.Interop/src/Java.Interop/
> Java.Interop/JniPeerMembers.JniInstanceMethods_Invoke.cs:67
>   at Android.Views.View.DispatchTouchEvent (Android.Views.MotionEvent e)
> [0x0002c] in
> /Users/builder/data/lanes/3819/96c7ba6c/source/monodroid/src/Mono.Android/
> platforms/android-23/src/generated/Android.Views.View.cs:12433
>   at Xamarin.Forms.Platform.Android.PlatformRenderer.DispatchTouchEvent
> (Android.Views.MotionEvent e) [0x00035] in
> C:\BuildAgent2\work\aad494dc9bc9783\Xamarin.Forms.Platform.
> Android\PlatformRenderer.cs:32
>   at Android.Views.View.n_DispatchTouchEvent_Landroid_view_MotionEvent_
> (System.IntPtr jnienv, System.IntPtr native__this, System.IntPtr native_e)
> [0x00011] in
> /Users/builder/data/lanes/3819/96c7ba6c/source/monodroid/src/Mono.Android/
> platforms/android-23/src/generated/Android.Views.View.cs:12420
>   at at (wrapper dynamic-method)
> System.Object:c598aa16-616f-467c-8c9c-b297525de4c4 (intptr,intptr,intptr)
> 
> I don't know if for you Xamarin guys can help you...
> 
> Cheers

Abel,

Based on your crash report, I believe you're seeing a different issue than the one originally reported. If you're still having this problem with the latest version of Xamarin Forms, please open a separate issue in Bugzilla.
Comment 28 E.Z. Hart 2017-01-31 22:18:49 UTC
(In reply to Robert Ewen from comment #18)
> We are getting same exception while making a touch on a listview.
> It only happens after the GC has done his job. for some reason, GC thinks he
> can remove a GestureDetector ...
> 
> Xamarin.Forms 2.3.3.168 (happend with 2.3.0.49 too)
> 
> The App is unusable, because we can not get around this crash ...
> 
> I/MonoDroid( 3501): UNHANDLED EXCEPTION:
> I/MonoDroid( 3501): System.ObjectDisposedException: Cannot access a disposed
> object.
> I/MonoDroid( 3501): Object name: 'Android.Views.GestureDetector'.
> I/MonoDroid( 3501):   at(wrapper managed-to-native)
> Java.Interop.NativeMethods:
> java_interop_jnienv_call_nonvirtual_boolean_method_a(intptr, intptr&,
> intptr, intptr, intptr, Java.Interop.JniArgumentValue*)
> I/MonoDroid( 3501):   at
> Java.Interop.JniEnvironment+InstanceMethods.CallNonvirtualBooleanMethod
> (Java.Interop.JniObjectReference instance, Java.Interop.JniObjectReference
> type, Java.Interop.JniMethodInfo method, Java.Interop.JniArgumentValue*
> args) [0x0008f] in
> /Users/builder/data/lanes/3511/ce955cc0/source/Java.Interop/src/Java.Interop/
> Java.Interop/JniEnvironment.g.cs:11728 
> I/MonoDroid( 3501):   at
> Java.Interop.JniPeerMembers+JniInstanceMethods.InvokeVirtualBooleanMethod
> (System.String encodedMember, Java.Interop.IJavaPeerable self,
> Java.Interop.JniArgumentValue* parameters) [0x0006b] in
> /Users/builder/data/lanes/3511/ce955cc0/source/Java.Interop/src/Java.Interop/
> Java.Interop/JniPeerMembers.JniInstanceMethods_Invoke.cs:67 
> I/MonoDroid( 3501):   at
> Android.Views.View.DispatchTouchEvent(Android.Views.MotionEvent e) [0x0002c]
> in
> /Users/builder/data/lanes/3511/ce955cc0/source/monodroid/src/Mono.Android/
> platforms/android-24/src/generated/Android.Views.View.cs:12619 
> I/MonoDroid( 3501):   at
> Xamarin.Forms.Platform.Android.PlatformRenderer.DispatchTouchEvent(Android.
> Views.MotionEvent e) [0x00035] in
> C:\BuildAgent2\work\ca3766cfc22354a1\Xamarin.Forms.Platform.
> Android\PlatformRenderer.cs:32 
> I/MonoDroid( 3501):   at
> Android.Views.View.n_DispatchTouchEvent_Landroid_view_MotionEvent_(System.
> IntPtr jnienv, System.IntPtr native__this, System.IntPtr native_e) [0x00011]
> in
> /Users/builder/data/lanes/3511/ce955cc0/source/monodroid/src/Mono.Android/
> platforms/android-24/src/generated/Android.Views.View.cs:12606 
> I/MonoDroid( 3501):   at(wrapper dynamic-method)
> System.Object:1d6ccd67-ae5f-4fd0-9e86-7a2026992447(intptr, intptr, intptr)
> E/mono-rt( 3501): Stacktrace:
> E/mono-rt( 3501): 
> E/mono-rt( 3501):   at<unknown> <0xffffffff>
> E/mono-rt( 3501):   at(wrapper managed-to-native)
> Java.Interop.NativeMethods.java_interop_jnienv_new_string
> (intptr,intptr&,char*,int) <0x00047>
> E/mono-rt( 3501):   at Java.Interop.JniEnvironment/Strings.NewString (char*,
> int) [0x0000a] in
> /Users/builder/data/lanes/3511/ce955cc0/source/Java.Interop/src/Java.Interop/
> Java.Interop/JniEnvironment.g.cs:13019
> E/mono-rt( 3501):   at Java.Interop.JniEnvironment/Strings.NewString
> (string) [0x00028] in
> /Users/builder/data/lanes/3511/ce955cc0/source/Java.Interop/src/Java.Interop/
> Java.Interop/JniEnvironment.Strings.cs:15
> E/mono-rt( 3501):   at Android.Runtime.JNIEnv.NewString(string) [0x0000c] in
> /Users/builder/data/lanes/3511/ce955cc0/source/xamarin-android/src/Mono.
> Android/Android.Runtime/JNIEnv.cs:937
> E/mono-rt( 3501):   at Java.Lang.Throwable..ctor(string) [0x00022] in
> /Users/builder/data/lanes/3511/ce955cc0/source/monodroid/src/Mono.Android/
> platforms/android-24/src/generated/Java.Lang.Throwable.cs:47
> E/mono-rt( 3501):   at
> Android.Runtime.JavaProxyThrowable..ctor(System.Exception) [0x00000] in
> /Users/builder/data/lanes/3511/ce955cc0/source/xamarin-android/src/Mono.
> Android/Android.Runtime/JavaProxyThrowable.cs:10
> E/mono-rt( 3501):   at Java.Lang.Throwable.FromException(System.Exception)
> [0x00023] in
> /Users/builder/data/lanes/3511/ce955cc0/source/xamarin-android/src/Mono.
> Android/Java.Lang/Throwable.cs:241
> E/mono-rt( 3501):   at
> Android.Runtime.AndroidEnvironment.UnhandledException(System.Exception)
> [0x0007e] in
> /Users/builder/data/lanes/3511/ce955cc0/source/xamarin-android/src/Mono.
> Android/Android.Runtime/AndroidEnvironment.cs:116
> E/mono-rt( 3501):   at(wrapper dynamic-method)
> object.1d6ccd67-ae5f-4fd0-9e86-7a2026992447(intptr, intptr, intptr) <IL
> 0x00030, 0x0009f>
> E/mono-rt( 3501):   at(wrapper native-to-managed)
> object.1d6ccd67-ae5f-4fd0-9e86-7a2026992447(intptr, intptr, intptr) <IL
> 0x00023, 0x000ff>

Robert,


Based on your crash report, I believe you're seeing a different issue than the one originally reported. If you're still having this problem with the latest version of Xamarin Forms, please open a separate issue in Bugzilla.
Comment 29 E.Z. Hart 2017-01-31 22:29:49 UTC
For everyone who has a stack trace which mentions a disposed 'Android.Views.GestureDetector', take a look at https://bugzilla.xamarin.com/show_bug.cgi?id=45330 to see if it might describe your problem.

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