我们正在使用名为 Sharpnado.Forms.HorizontalListView
的第三方组件每次我们都想使用以下方法将对象放置在Android Custom Renderer中:
Control.GetAdapter()?.Dispose();
应用程序崩溃(请参见下面的错误堆栈)
如果不调用Dispose,则不会发生崩溃,但是可能会发生内存泄漏。
问题:
1-我们可以从侧面解决此问题,还是只能依靠第三方组件所有者来解决此问题?
2-是否有其他方法可以进行此处理?
谢谢
[MonoDroid] System.NullReferenceException: Object reference not set to an instance of an object.
[MonoDroid] at Sharpnado.Presentation.Forms.Droid.Renderers.HorizontalList.AndroidHorizontalListViewRenderer+RecycleViewAdapter.get_ItemCount () [0x00000] in D:\Dev\Sharpnado\src\Xamarin-Forms-Practices\Sharpnado.Presentation.Forms\Sharpnado.Presentation.Forms.Droid\Renderers\HorizontalList\AndroidHorizontalListViewRenderer.RecycleViewAdapter.cs:93
[MonoDroid] at Android.Support.V7.Widget.RecyclerView+Adapter.n_GetItemCount (System.IntPtr jnienv, System.IntPtr native__this) [0x00008] in <7cd821e41c6245e986359cd08947256b>:0
[MonoDroid] at (wrapper dynamic-method) System.Object.88(intptr,intptr)
...
[AppCenterCrashes] Unhandled Exception from source=AndroidEnvironment
[AppCenterCrashes] System.NullReferenceException: Object reference not set to an instance of an object.
[AppCenterCrashes] at Sharpnado.Presentation.Forms.Droid.Renderers.HorizontalList.AndroidHorizontalListViewRenderer+RecycleViewAdapter.get_ItemCount () [0x00000] in D:\Dev\Sharpnado\src\Xamarin-Forms-Practices\Sharpnado.Presentation.Forms\Sharpnado.Presentation.Forms.Droid\Renderers\HorizontalList\AndroidHorizontalListViewRenderer.RecycleViewAdapter.cs:93
[AppCenterCrashes] at Android.Support.V7.Widget.RecyclerView+Adapter.n_GetItemCount (System.IntPtr jnienv, System.IntPtr native__this) [0x00008] in <7cd821e41c6245e986359cd08947256b>:0
[AppCenterCrashes] at (wrapper dynamic-method) System.Object.88(intptr,intptr)
...
[Mono] Assembly Ref addref Microsoft.AppCenter.Crashes[0x7096654600] -> System.Core[0x70966d7c00]: 20
...
[Mono] DllImport searching in: '__Internal' ('(null)').
[Mono] Searching for 'java_interop_jnienv_new_byte_array'.
[Mono] Probing 'java_interop_jnienv_new_byte_array'.
[Mono] Found as 'java_interop_jnienv_new_byte_array'.
[Mono] DllImport searching in: '__Internal' ('(null)').
[Mono] Searching for 'java_interop_jnienv_set_byte_array_region'.
[Mono] Probing 'java_interop_jnienv_set_byte_array_region'.
[Mono] Found as 'java_interop_jnienv_set_byte_array_region'.
[zygote64] Checksum mismatch for dex base.apk:classes2.dex
[zygote64] Checksum mismatch for dex base.apk:classes2.dex
[zygote64] JNI RegisterNativeMethods: attempt to register 0 native methods for android.runtime.JavaProxyThrowable
[Mono] DllImport searching in: '__Internal' ('(null)').
[Mono] Searching for 'java_interop_jnienv_throw'.
[Mono] Probing 'java_interop_jnienv_throw'.
[Mono] Found as 'java_interop_jnienv_throw'.