0

I am trying to get notifications up and running in my Xamarin.Android project. For some reason, when I run the app on my phone, it crashes and returns null. I've been dealing with this for a while now, but I don't seem to understand what the problem is.

I already tried with saving the context on a variable at the beggining and calling it later when needed, but it doesn't work either.

Here is my OnCreate method, including the line that causes the error:

protected override void OnCreate(Bundle bundle)
{
    if (Intent.Extras != null)
    {
        foreach (var key in Intent.Extras.KeySet())
        {
            var value = Intent.Extras.GetString(key);
            Log.Debug(TAG, "Key: {0} Value: {1}", key, value);
        }
    }

    TabLayoutResource = Resource.Layout.Tabbar;
    ToolbarResource = Resource.Layout.Toolbar;
    base.OnCreate(bundle);

    if (!Resolver.IsSet) SetIoc();
    LayoutInflater inflater;
    Context context = this.BaseContext;
    inflater = LayoutInflater.FromContext(context);
    View dialogView = inflater.Inflate(Resource.Layout.Main, null);
    SetContentView(Resource.Layout.Main);
    msgText = dialogView.FindViewById<TextView>(Resource.Id.msgText);

    IsPlayServicesAvailable();
    Xamarin.FormsMaps.Init(this, bundle);
    Xamarin.Forms.Forms.Init(this, bundle);
    FormsControls.Droid.Main.Init(this); //this one is crashing
    LoadApplication(new App());
    FirebaseApp app = FirebaseApp.InitializeApp(this);
    ConfigureFireBase();
}
  • 1
    Possible duplicate of [What is a NullReferenceException, and how do I fix it?](https://stackoverflow.com/questions/4660142/what-is-a-nullreferenceexception-and-how-do-i-fix-it) – Aleks Andreev Oct 23 '17 at 18:02
  • I already tried to fix it guided by that post, but I couldn't do so. I think I may be doing something that causes involved NuGets to crash. Maybe I'm wrong tho, but that's why I'm asking. – Mauricio Cárdenas Oct 23 '17 at 20:01
  • `FormsControls.Droid.Main.Init(this);`, seems like you installed some third-party lib, which lib are you using? Usually we need to submit issue to that lib, but if it has open source on github, maybe we can try to understand what causes this problem together. And by the way, does this issue happens each time when you open your app or launch your app from notification? – Grace Feng Oct 24 '17 at 06:44
  • This is a project I'm working on, but not a project I started. I'll be honest, I don't know what library he was using, but he said he was not using any lib for that line. I'm still tracking where is it coming from. Apparently it's Xamarin's custom navigation https://components.xamarin.com/gettingstarted/customnavpage – Mauricio Cárdenas Oct 24 '17 at 18:15

0 Answers0