Xamarin Forms Sample throws exception on back button press on Android
Xamarin Forms sample has a VideoView on the main screen and OnAppearing it plays a video.
But when android back button is pressed it throws exception showing app unfortunately stopped.
Same error happens if navigating away from a page with a VideoView.
Could anyone point out how to release/clean p the VideoView properly in Xamarin Forms i.e. inside page OnDisappearing()
Stack trace:
11-10 14:15:25.697: E/AndroidRuntime(4416): android.runtime.JavaProxyThrowable: System.NullReferenceException: Object reference not set to an instance of an object
11-10 14:15:25.697: E/AndroidRuntime(4416): at LibVLCSharp.Platforms.Android.VideoView.Detach () [0x00000] in <1c37741b205d4dfc8a66f630270b687c>:0
11-10 14:15:25.697: E/AndroidRuntime(4416): at LibVLCSharp.Platforms.Android.VideoView.Dispose (System.Boolean disposing) [0x00007] in <1c37741b205d4dfc8a66f630270b687c>:0
11-10 14:15:25.697: E/AndroidRuntime(4416): at Java.Lang.Object.Dispose () [0x00000] in <a10f61e70eeb434e952fef884856c199>:0
11-10 14:15:25.697: E/AndroidRuntime(4416): at LibVLCSharp.Forms.Platforms.Android.VideoViewRenderer.Dispose (System.Boolean disposing) [0x00007] in <c7b771799f6248029f9cd408af3d81e9>:0
11-10 14:15:25.697: E/AndroidRuntime(4416): at Java.Lang.Object.Dispose () [0x00000] in <a10f61e70eeb434e952fef884856c199>:0
11-10 14:15:25.697: E/AndroidRuntime(4416): at Xamarin.Forms.Platform.Android.VisualElementRenderer`1[TElement].Dispose (System.Boolean disposing) [0x0007b] in <3a92ee483a4c4993b499f9c6bb09c7b9>:0
11-10 14:15:25.697: E/AndroidRuntime(4416): at Xamarin.Forms.Platform.Android.Platform+DefaultRenderer.Dispose (System.Boolean disposing) [0x0000a] in <3a92ee483a4c4993b499f9c6bb09c7b9>:0
11-10 14:15:25.697: E/AndroidRuntime(4416): at Java.Lang.Object.Dispose () [0x00000] in <a10f61e70eeb434e952fef884856c199>:0
11-10 14:15:25.697: E/AndroidRuntime(4416): at Xamarin.Forms.Platform.Android.VisualElementRenderer`1[TElement].Dispose (System.Boolean disposing) [0x0007b] in <3a92ee483a4c4993b499f9c6bb09c7b9>:0
11-10 14:15:25.697: E/AndroidRuntime(4416): at Xamarin.Forms.Platform.Android.PageRenderer.Dispose (System.Boolean disposing) [0x00011] in <3a92ee483a4c4993b499f9c6bb09c7b9>:0
11-10 14:15:25.697: E/AndroidRuntime(4416): at Java.Lang.Object.Dispose () [0x00000] in <a10f61e70eeb434e952fef884856c199>:0
11-10 14:15:25.697: E/AndroidRuntime(4416): at Xamarin.Forms.Platform.Android.AppCompat.FragmentContainer.OnDestroyView () [0x0003c] in <3a92ee483a4c4993b499f9c6bb09c7b9>:0
11-10 14:15:25.697: E/AndroidRuntime(4416): at Android.Support.V4.App.Fragment.n_OnDestroyView (System.IntPtr jnienv, System.IntPtr native__this) [0x00008] in <21e4bb539f4a49b58a498749b367d2a8>:0
11-10 14:15:25.697: E/AndroidRuntime(4416): at (wrapper dynamic-method) System.Object.30(intptr,intptr)
11-10 14:15:25.697: E/AndroidRuntime(4416): --- End of stack trace from previous location where exception was thrown ---
11-10 14:15:25.697: E/AndroidRuntime(4416): at Java.Interop.JniEnvironment+InstanceMethods.CallNonvirtualVoidMethod (Java.Interop.JniObjectReference instance, Java.Interop.JniObjectReference type, Java.Interop.JniMethodInfo method, Java.Interop.JniArgumentValue* args) [0x00089] in <034d4a9852dd45bea9353cc7776c99f0>:0
11-10 14:15:25.697: E/AndroidRuntime(4416): at Java.Interop.JniPeerMembers+JniInstanceMethods.InvokeVirtualVoidMethod (System.String encodedMember, Java.Interop.IJavaPeerable self, Java.Interop.JniArgumentValue* parameters) [0x0005d] in <034d4a9852dd45bea9353cc7776c99f0>:0
11-10 14:15:25.697: E/AndroidRuntime(4416): at Android.App.Activity.OnDestroy () [0x0000a] in <a10f61e70eeb434e952fef884856c199>:0
11-10 14:15:25.697: E/AndroidRuntime(4416): at Xamarin.Forms.Platform.Android.FormsAppCompatActivity.OnDestroy () [0x00017] in <3a92ee483a4c4993b499f9c6bb09c7b9>:0
11-10 14:15:25.697: E/AndroidRuntime(4416): at Android.App.Activity.n_OnDestroy (System.IntPtr jnienv, System.IntPtr native__this) [0x00009] in <a10f61e70eeb434e952fef884856c199>:0
11-10 14:15:25.697: E/AndroidRuntime(4416): at (wrapper dynamic-method) System.Object.8(intptr,intptr)
11-10 14:15:25.697: E/AndroidRuntime(4416): at md51558244f76c53b6aeda52c8a337f2c37.FormsAppCompatActivity.n_onDestroy(Native Method)
11-10 14:15:25.697: E/AndroidRuntime(4416): at md51558244f76c53b6aeda52c8a337f2c37.FormsAppCompatActivity.onDestroy(FormsAppCompatActivity.java:80)
11-10 14:15:25.697: E/AndroidRuntime(4416): at android.app.Activity.performDestroy(Activity.java:6407)
11-10 14:15:25.697: E/AndroidRuntime(4416): at android.app.Instrumentation.callActivityOnDestroy(Instrumentation.java:1142)
11-10 14:15:25.697: E/AndroidRuntime(4416): at android.app.ActivityThread.performDestroyActivity(ActivityThread.java:3818)
11-10 14:15:25.697: E/AndroidRuntime(4416): at android.app.ActivityThread.handleDestroyActivity(ActivityThread.java:3849)
11-10 14:15:25.697: E/AndroidRuntime(4416): at android.app.ActivityThread.-wrap5(ActivityThread.java)
11-10 14:15:25.697: E/AndroidRuntime(4416): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1398)
11-10 14:15:25.697: E/AndroidRuntime(4416): at android.os.Handler.dispatchMessage(Handler.java:102)
11-10 14:15:25.697: E/AndroidRuntime(4416): at android.os.Looper.loop(Looper.java:148)
11-10 14:15:25.697: E/AndroidRuntime(4416): at android.app.ActivityThread.main(ActivityThread.java:5417)
11-10 14:15:25.697: E/AndroidRuntime(4416): at java.lang.reflect.Method.invoke(Native Method)
11-10 14:15:25.697: E/AndroidRuntime(4416): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:726)
11-10 14:15:25.697: E/AndroidRuntime(4416): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616)