Xamarin.Forms IOS Crash on start with System.NullReferenceException

TerranceSmithTerranceSmith USMember ✭✭
edited May 3 in Xamarin.Forms

Hey all,

My app is crashing on Startup and I've gone through a lot of tinkering to get it to where it is.
My app crashes when attempting to instantiate my PCL Forms App class in IO

I've tried running it without debugging

I've tried set breakpoints but Xamarin Studio isn't picking them up.

I've gone back and forth on the stack trace and toggled the build output to Diagnostic to see if there is a hint in the build log.

I've verified my Developer Profile and Bundle Signing Identity are set to the defaults.

This project is essentially a solution rebuild of a previous version pulling in some existing code and resources. It was working until I updated my App file and added a bunch of nuget refs. I can't pinpoint the exact cause of the beginning of the runtime fail. I am referencing .netcore and I have recompiled stripe.net to be referenceable by PCL.

EventProMobile App code (partial)

https://pastebin.com/79fbx9Uf

csharp
public partial class App : Application
{
    public App()
    {
        LogHelper.LogDebug("At the start of the constructor");
        InitializeComponent();
        //note* the namespace is EventProMobile
        MainPage = new NavigationPage(new Xamarin.Forms.Page());
    }

    protected override void OnStart()
    {
        // Handle when your app starts
        MobileCenter.Start(typeof(Analytics), typeof(Crashes));
        BlobCache.ApplicationName = "EventPro";
        MainPage = RunCredentialCheck();
    }
}

EventProMobile.iOS AppDelegate code

https://pastebin.com/hyk9V0Dh

csharp
using System.Diagnostics;
using EventProApp.iOS;
using FFImageLoading.Forms.Touch;
using Foundation;
using UIKit;

namespace EventProMobile.iOS
{
    [Register("AppDelegate")]
    public partial class AppDelegate : global::Xamarin.Forms.Platform.iOS.FormsApplicationDelegate
    {
        public override bool FinishedLaunching(UIApplication app, NSDictionary options)
        {
            try
            {
                Xamarin.Forms.Forms.Init();
                EventProMobile.App.Logger.Write("Test", Splat.LogLevel.Debug);
                var formsApp = new EventProMobile.App();
                Debug.Assert(formsApp != null,"App should not be null after instantiation.");
                LoadApplication(formsApp);
                return base.FinishedLaunching(app, options);
            }
            catch (System.Exception ex)
            {
                Debug.Write($"Error on FinishedLaunching: {ex.Message}");
                throw ex;
            }
        }
    }
}

My packages for My PCL project

  package id="akavache.core" version="5.0.0" targetFramework="portable45-net45+win8+wpa81" 
  package id="akavache.sqlite3" version="5.0.0" targetFramework="portable45-net45+win8+wpa81" 
  package id="AsyncErrorHandler.Fody" version="1.1.0" targetFramework="portable45-net45+win8+wpa81" developmentDependency="true" 
  package id="CClarke.Plugin.Calendars" version="0.6.33-beta" targetFramework="portable45-net45+win8+wpa81" 
  package id="CommonServiceLocator" version="1.3" targetFramework="portable45-net45+win8+wpa81" 
  package id="Fody" version="2.0.6" targetFramework="portable45-net45+win8+wpa81" developmentDependency="true" 
  package id="fusillade" version="0.7.0" targetFramework="portable45-net45+win8+wpa81" 
  package id="Microsoft.Azure.Mobile" version="0.9.2" targetFramework="portable45-net45+win8+wpa81" 
  package id="Microsoft.Azure.Mobile.Analytics" version="0.9.2" targetFramework="portable45-net45+win8+wpa81" 
  package id="Microsoft.Azure.Mobile.Crashes" version="0.9.2" targetFramework="portable45-net45+win8+wpa81" 
  package id="Microsoft.Net.Compilers" version="2.1.0" targetFramework="portable45-net45+win8+wpa81" developmentDependency="true" 
  package id="Microsoft.NETCore.Platforms" version="1.1.0" targetFramework="portable45-net45+win8+wpa81" 
  package id="Microsoft.NETCore.Targets" version="1.1.0" targetFramework="portable45-net45+win8+wpa81" 
  package id="modernhttpclient" version="2.4.2" targetFramework="portable45-net45+win8+wpa81" 
  package id="MvvmLightLibs" version="5.3.0.0" targetFramework="portable45-net45+win8+wpa81" 
  package id="NETStandard.Library" version="1.6.1" targetFramework="portable45-net45+win8+wpa81" 
  package id="Newtonsoft.Json" version="7.0.1" targetFramework="portable45-net45+win8+wpa81" 
  package id="Plugin.Permissions" version="1.2.1" targetFramework="portable45-net45+win8+wpa81" 
  package id="Plugin.Share" version="6.1.0.19-beta" targetFramework="portable45-net45+win8+wpa81" 
  package id="Polly" version="5.0.6" targetFramework="portable45-net45+win8+wpa81" 
  package id="PropertyChanged.Fody" version="1.53.0" targetFramework="portable45-net45+win8+wpa81" developmentDependency="true" 
  package id="Punchclock" version="1.1.1" targetFramework="portable45-net45+win8+wpa81" 
  package id="reactiveui" version="7.0.0" targetFramework="portable45-net45+win8+wpa81" 
  package id="ReactiveUI.Fody" version="2.2.3" targetFramework="portable45-net45+win8+wpa81" 
  package id="reactiveui-core" version="7.2.0" targetFramework="portable45-net45+win8+wpa81" 
  package id="reactiveui-xamforms" version="7.2.0" targetFramework="portable45-net45+win8+wpa81" 
  package id="refit-linker" version="2.3.0" targetFramework="portable45-net45+win8+wpa81" 
  package id="runtime.native.System" version="4.3.0" targetFramework="portable45-net45+win8+wpa81" 
  package id="Rx-Core" version="2.2.5" targetFramework="portable45-net45+win8+wpa81" 
  package id="Rx-Interfaces" version="2.2.5" targetFramework="portable45-net45+win8+wpa81" 
  package id="Rx-Linq" version="2.2.5" targetFramework="portable45-net45+win8+wpa81" 
  package id="Rx-Main" version="2.2.5" targetFramework="portable45-net45+win8+wpa81" 
  package id="Rx-PlatformServices" version="2.2.5" targetFramework="portable45-net45+win8+wpa81" 
  package id="Splat" version="1.6.2" targetFramework="portable45-net45+win8+wpa81" 
  package id="SQLitePCLRaw.bundle_e_sqlite3" version="1.1.0" targetFramework="portable45-net45+win8+wpa81" 
  package id="SQLitePCLRaw.core" version="1.1.0" targetFramework="portable45-net45+win8+wpa81" 
  package id="System.Collections" version="4.3.0" targetFramework="portable45-net45+win8+wpa81" 
  package id="System.Collections.Concurrent" version="4.3.0" targetFramework="portable45-net45+win8+wpa81" 
  package id="System.Diagnostics.Debug" version="4.3.0" targetFramework="portable45-net45+win8+wpa81" 
  package id="System.Diagnostics.Tools" version="4.3.0" targetFramework="portable45-net45+win8+wpa81" 
  package id="System.Diagnostics.Tracing" version="4.3.0" targetFramework="portable45-net45+win8+wpa81" 
  package id="System.Globalization" version="4.3.0" targetFramework="portable45-net45+win8+wpa81" 
  package id="System.IO" version="4.3.0" targetFramework="portable45-net45+win8+wpa81" 
  package id="System.IO.Compression" version="4.3.0" targetFramework="portable45-net45+win8+wpa81" 
  package id="System.Linq" version="4.3.0" targetFramework="portable45-net45+win8+wpa81" 
  package id="System.Linq.Expressions" version="4.3.0" targetFramework="portable45-net45+win8+wpa81" 
  package id="System.Net.Http" version="4.3.0" targetFramework="portable45-net45+win8+wpa81" 
  package id="System.Net.Primitives" version="4.3.0" targetFramework="portable45-net45+win8+wpa81" 
  package id="System.ObjectModel" version="4.3.0" targetFramework="portable45-net45+win8+wpa81" 
  package id="System.Reflection" version="4.3.0" targetFramework="portable45-net45+win8+wpa81" 
  package id="System.Reflection.Extensions" version="4.3.0" targetFramework="portable45-net45+win8+wpa81" 
  package id="System.Reflection.Primitives" version="4.3.0" targetFramework="portable45-net45+win8+wpa81" 
  package id="System.Resources.ResourceManager" version="4.3.0" targetFramework="portable45-net45+win8+wpa81" 
  package id="System.Runtime" version="4.3.0" targetFramework="portable45-net45+win8+wpa81" 
  package id="System.Runtime.Extensions" version="4.3.0" targetFramework="portable45-net45+win8+wpa81" 
  package id="System.Runtime.InteropServices" version="4.3.0" targetFramework="portable45-net45+win8+wpa81" 
  package id="System.Runtime.InteropServices.RuntimeInformation" version="4.3.0" targetFramework="portable45-net45+win8+wpa81" 
  package id="System.Runtime.Numerics" version="4.3.0" targetFramework="portable45-net45+win8+wpa81" 
  package id="System.Text.Encoding" version="4.3.0" targetFramework="portable45-net45+win8+wpa81" 
  package id="System.Text.Encoding.Extensions" version="4.3.0" targetFramework="portable45-net45+win8+wpa81" 
  package id="System.Text.RegularExpressions" version="4.3.0" targetFramework="portable45-net45+win8+wpa81" 
  package id="System.Threading" version="4.3.0" targetFramework="portable45-net45+win8+wpa81" 
  package id="System.Threading.Tasks" version="4.3.0" targetFramework="portable45-net45+win8+wpa81" 
  package id="System.Xml.ReaderWriter" version="4.3.0" targetFramework="portable45-net45+win8+wpa81" 
  package id="System.Xml.XDocument" version="4.3.0" targetFramework="portable45-net45+win8+wpa81" 
  package id="Xam.Plugin.Connectivity" version="2.3.0" targetFramework="portable45-net45+win8+wpa81" 
  package id="Xamarin.FFImageLoading" version="2.2.9" targetFramework="portable45-net45+win8+wpa81" 
  package id="Xamarin.FFImageLoading.Forms" version="2.2.9" targetFramework="portable45-net45+win8+wpa81" 
  package id="Xamarin.Forms" version="2.3.4.231" targetFramework="portable45-net45+win8+wpa81"

My packages.config for my IOS Project

  package id="akavache.core" version="5.0.0" targetFramework="xamarinios10" 
  package id="akavache.sqlite3" version="5.0.0" targetFramework="xamarinios10" 
  package id="CClarke.Plugin.Calendars" version="0.6.33-beta" targetFramework="xamarinios10" 
  package id="Microsoft.Azure.Mobile" version="0.9.2" targetFramework="xamarinios10" 
  package id="Microsoft.Azure.Mobile.Analytics" version="0.9.2" targetFramework="xamarinios10" 
  package id="Microsoft.Azure.Mobile.Crashes" version="0.9.2" targetFramework="xamarinios10" 
  package id="Newtonsoft.Json" version="6.0.3" targetFramework="xamarinios10" 
  package id="Plugin.Permissions" version="1.2.1" targetFramework="xamarinios10" 
  package id="Plugin.Share" version="6.1.0.19-beta" targetFramework="xamarinios10" 
  package id="reactiveui" version="7.2.0" targetFramework="xamarinios10" 
  package id="reactiveui-core" version="7.2.0" targetFramework="xamarinios10" 
  package id="Rx-Core" version="2.2.5" targetFramework="xamarinios10" 
  package id="Rx-Interfaces" version="2.2.5" targetFramework="xamarinios10" 
  package id="Rx-Linq" version="2.2.5" targetFramework="xamarinios10" 
  package id="Rx-Main" version="2.2.5" targetFramework="xamarinios10" 
  package id="Rx-PlatformServices" version="2.2.5" targetFramework="xamarinios10" 
  package id="Splat" version="1.6.0" targetFramework="xamarinios10" 
  package id="SQLitePCLRaw.bundle_e_sqlite3" version="1.1.0" targetFramework="xamarinios10" 
  package id="SQLitePCLRaw.core" version="1.1.0" targetFramework="xamarinios10" 
  package id="SQLitePCLRaw.lib.e_sqlite3.ios_unified.static" version="1.1.0" targetFramework="xamarinios10" 
  package id="SQLitePCLRaw.provider.internal.ios_unified" version="1.1.0" targetFramework="xamarinios10" 
  package id="WebP.Touch" version="1.0.3" targetFramework="xamarinios10" 
  package id="Xam.Plugin.Connectivity" version="2.3.0" targetFramework="xamarinios10" 
  package id="Xamarin.FFImageLoading" version="2.2.9" targetFramework="xamarinios10" 
  package id="Xamarin.FFImageLoading.Forms" version="2.2.9" targetFramework="xamarinios10" 
  package id="Xamarin.Forms" version="2.3.4.231" targetFramework="xamarinios10" 
  package id="Xamarin.TestCloud.Agent" version="0.20.3" targetFramework="xamarinios10" 

Approx 30 second gif of the crash

The IOS Debug Config

The IOS Build Config

The Xamarin Forms PCL General Config

Pic of the Stack Trace

The Exception being thrown

Answers

  • LuisRodriguez92LuisRodriguez92 USMember ✭✭✭

    ENABLE_TEST_CLOUD, Does it exist in conditional compilation symbols?

    check this, >>>> project PCL > Propiertes > Build (VisualStudio)

    in Xamarin for Mac

    Imagen

  • TerranceSmithTerranceSmith USMember ✭✭

    @LuisRodriguez92 it is. My full list of Debug Symbols :

    "UNIFIED;MOBILE;IOS;DEBUG;ENABLE_TEST_CLOUD;"

  • IgorStrekhaIgorStrekha USMember ✭✭

    @TerranceSmith said:
    @LuisRodriguez92 it is. My full list of Debug Symbols :

    "UNIFIED;MOBILE;IOS;DEBUG;ENABLE_TEST_CLOUD;"

    I have this problem also. Do you found how fixed?

  • IgorGoldobinIgorGoldobin USMember

    @TerranceSmith Any luck with this issue?

  • TerranceSmithTerranceSmith USMember ✭✭

    Hey all, what ended up working.

    I removed all my extra initialization code.

    • Akavache
    • Azure Mobile Crash reporting
    • AWS log initialization
      And anything else that requires Sqlite access.

    Turns out the issue was caused by related to multiple conflicting inits being called on the db. This may have been fixed in the latest.

    https://github.com/akavache/Akavache/commit/cf13baeb4415351111c11608ab950b0e0aabb7ee

    But, I ended up taking out Akavache from my code base and rebuilt it using SqliteOrm.

    Akavache was amazing when it was working but, it was a pain in the butt when it wasn't.

  • batmacibatmaci DEMember ✭✭✭✭

    It doesnt seem to be fixed. I have akavache latest pre release installed. it is still crashing. :(

Sign In or Register to comment.