-
Notifications
You must be signed in to change notification settings - Fork 1.9k
Object reference not set to an instance with Android.ShellSectionRenderer.UnhookEvents () #6640
Comments
@rpdomingo Can you please attach a small project that demonstrates this issue? Thanks! |
@samhouts Thanks for the reply. Please clone my repo https://github.com/rpdomingo/Xamarin.Forms.4.0 I've Tested in Xamain.Forms.4.0.0.425677 to 4.0.0.497661 I use API 23 android. Samsung S6. Additional: Thank you |
|
@samhouts will wait this till resolved. Thank you :) |
Thanks for the repro. |
@kvpt Thanks for the info. Hope this will resolved soon. 🙂 |
From the code and some tests, it's appear that the dispose of the shell components are completely broken 😱. @samhouts I can try to fix this, but I don't know well the code of the shell at this time. @rpdomingo Until a fix is made you can bypass the crash with the use of a custom renderer which dont null the shell in the dispose, like this. [assembly: ExportRenderer(typeof(Shell), typeof(ShellRendererCustomDispose))]
namespace App.Droid.Renderers
{
public class ShellRendererCustomDispose : ShellRenderer
{
bool _disposed;
public ShellRendererCustomDispose(Context context)
: base(context)
{
}
protected override void Dispose(bool disposing)
{
if (_disposed)
{
return;
}
if (disposing)
{
Element.PropertyChanged -= OnElementPropertyChanged;
Element.SizeChanged -= (EventHandler)Delegate.CreateDelegate(typeof(EventHandler), this, "OnElementSizeChanged"); // OnElementSizeChanged is private, so use reflection
}
_disposed = true;
}
}
} |
From #7435 I see it also happens when using split screen. Although it's probably the same cause because of the lifecycle events, it might be worth to explicitly test that scenario. |
From the stacktrace the crash is issue from the OnDestroy.
From the stacktrace the crash is trigerred by the component destroy event. |
Just got this one on |
Could I help You with this task? |
I have the same problem anyone found a way around? |
This worked for my app: |
perfect. tank's! |
closed by #7768 |
So, is this resolved in 4.3? Sorry, can't determine from the logs... |
@kvpt I added the above code to new class in my project, but, cannot build, get 2 errors on build now:
Maybe it's how I added this class? I copied code exactly as you have provided, and, named the class ShellRendererCustomDispose.cs in the root of my Android project. |
@dbwelch Replace the namespace, App.Droid.Renderers in the example with the namespace of your app. |
@kvpt Thanks, that makes sense. In the meantime, I replaced my Xamarin.Forms to 4.3.0.947036, and now I do not get the exception also! Will probably keep it. Btw, my issue a little different, I received this error when I click on a notification that takes me back to the app, but, same exception as noted in this issue. Thanks for the post! |
Thanks for fixing this one 👍 |
Description
Object reference not set to an instance after clicking log out in MasterdetailPage(This is Shell). And then press the hardware back button of Android.
Steps to Reproduce
Expected Behavior
When login successfully Go to MasterPage(This is Shell) using App.Current.MainPage = MasterPage() and click log out will go to Login Page. I use App.Current.MainPage = Loginpage and then press the hardware back button of Android. It will terminate the app.
Actual Behavior
After Logout and press hardware back button of Android. Object reference not set to an instance shown.
Basic Information
Screenshots
Reproduction Link
The text was updated successfully, but these errors were encountered: