TobiasBuchholz / Plugin.Firebase

Wrapper around the native Android and iOS Firebase Xamarin SDKs
MIT License
211 stars 49 forks source link

IOS CrossFirebaseCrashlytics.Current object is null #224

Closed krazazian closed 3 months ago

krazazian commented 11 months ago

I've set up my project correctly based on the setup documentation, but I'm always getting an object null reference exception on the CrossFirebaseCrashlytics.Current.SetCrashlyticsCollectionEnabled(true); call. Am I missing something in the setup for iOS?

` builder.ConfigureLifecycleEvents(events => {

if IOS

            events.AddiOS(iOS => iOS.FinishedLaunching((_, __) => 
            {
                //CrossFirebase.Initialize(CreateCrossFirebaseSettings());
                CrossFirebase.Initialize();
                FirebaseCloudMessagingImplementation.Initialize();
                try
                {
                    **CrossFirebaseCrashlytics.Current.SetCrashlyticsCollectionEnabled(true);**
                }
                catch { }

                return false;
            }));

else`

TobiasBuchholz commented 10 months ago

Could you please provide a sample project that demonstrates this issue?

Gius95 commented 10 months ago

I've the same problem here, i'm using .NET8.0 with the following dependencies.

<ItemGroup>
    <PackageReference Include="CommunityToolkit.Maui" Version="7.0.0" />
    <PackageReference Include="CommunityToolkit.Mvvm" Version="8.2.2" />
    <PackageReference Include="MetroLog.Maui" Version="2.1.0" />
    <PackageReference Include="MetroLog.Net6" Version="2.1.0" />
    <PackageReference Include="Plugin.Firebase.Auth" Version="2.0.5" />
    <PackageReference Include="Plugin.Firebase.CloudMessaging" Version="2.0.4" />
    <PackageReference Include="Plugin.Firebase.Crashlytics" Version="2.0.1" />
    <PackageReference Include="Plugin.LocalNotification" Version="10.1.8" />
    <PackageReference Include="Shiny.Hosting.Maui" Version="3.1.2" />
    <PackageReference Include="Shiny.Jobs" Version="3.1.2" />
    <PackageReference Include="Shiny.Locations" Version="3.1.2" />
    <PackageReference Include="Shiny.Notifications" Version="3.1.2" />
    <PackageReference Include="sqlite-net-pcl" Version="1.8.116" />
    <PackageReference Include="SQLitePCLRaw.bundle_green" Version="2.1.6" />
    <PackageReference Include="System.IdentityModel.Tokens.Jwt" Version="7.0.3" />
    <PackageReference Include="Prism.DryIoc.Maui" Version="9.0.271-pre" />
    <PackageReference Include="Xamarin.Build.Download" Version="0.11.4" />
</ItemGroup>

<ItemGroup Condition="'$(TargetFramework)' == 'net8.0-android'">
    <PackageReference Include="Xamarin.AndroidX.Core" Version="1.12.0.2" />
    <PackageReference Include="Xamarin.AndroidX.Collection" Version="1.3.0.1" />
    <PackageReference Include="Xamarin.AndroidX.Collection.Ktx" Version="1.3.0.1" />
    <PackageReference Include="Xamarin.AndroidX.Activity.Ktx" Version="1.8.0.1" />
    <PackageReference Include="Xamarin.AndroidX.Browser" Version="1.6.0.2" />
</ItemGroup>

And if I uncomment one of these 2 lines it crashes with a null exception on Current object. image

krazazian commented 10 months ago

@TobiasBuchholz - basically the same thing that @Gius95 has mentioned above

d66ni commented 7 months ago

@TobiasBuchholz - I have the same issue as mentioned above. Are there any news about this issue? CorssFirebaseCrashlytics is always NULL in my case ...

iida-i3 commented 3 months ago

Probably I'm encountering the same problem. I have uploaded a simple sample project. https://github.com/iida-i3/FirebaseExperiment

AdamEssenmacher commented 3 months ago

It's not possible for CrossFirebaseCrashlytics.Current to return null.

Please call CrossFirebase.Initialize() during WillFinishLaunching as shown in the basic setup instructions

iida-i3 commented 3 months ago

Lots of strangeness, but I was able to try it anyway. Thanks for the reply.

(P.S.) I was able to try, but still have problem. Specifically, I used version 3.0.0, but it only shows xamarin_find_protocol_wrapper_type. I will continue to look into other Issues, etc. Stacktrace:

          Crashed: tid_103
0  libsystem_kernel.dylib         0xc42c __pthread_kill + 8
1  libsystem_pthread.dylib        0x7c0c pthread_kill + 268
2  libsystem_c.dylib              0x75ba0 abort + 180
3  FirebaseExperiment.iOS         0x1537030 xamarin_find_protocol_wrapper_type + 1201 (runtime.m:1201)
4  FirebaseExperiment.iOS         0x1731744 mono_invoke_unhandled_exception_hook + 1263 (exception.c:1263)
5  FirebaseExperiment.iOS         0x17d158c mono_jit_exec + 1375 (driver.c:1375)
6  FirebaseExperiment.iOS         0x153f58c xamarin_main + 495 (monotouch-main.m:495)
7  FirebaseExperiment.iOS         0x1839f14 main + 202 (main.arm64.mm:202)
8  ???                            0x1c31c1e4c (シンボルが不足しています)