Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Default FirebaseApp is not initialized #1072

Open
mirogrg1 opened this issue Jan 9, 2025 · 0 comments
Open

Default FirebaseApp is not initialized #1072

mirogrg1 opened this issue Jan 9, 2025 · 0 comments

Comments

@mirogrg1
Copy link

mirogrg1 commented Jan 9, 2025

Android framework version

net8.0-android

Affected platform version

VS 2022 17.12.3, .NET 8

Description

I keep getting this error in my .NET MAUI Android app while using Xamarin.Firebase.Messaging package, which is referenced in https://learn.microsoft.com/en-us/dotnet/maui/data-cloud/push-notifications?view=net-maui-9.0 :

Java.Lang.IllegalStateException: 'Default FirebaseApp is not initialized in this process com.tendrils. Make sure to call FirebaseApp.initializeApp(Context) first.'

Image

Image

Project file:

<?xml version="1.0" encoding="utf-8"?>
<Project Sdk="Microsoft.NET.Sdk">
  <PropertyGroup>
    <TargetFrameworks>net8.0-android;net8.0-ios</TargetFrameworks>    
    <OutputType>Exe</OutputType>
    <RootNamespace>Tendrils</RootNamespace>
    <UseMaui>true</UseMaui>
    <SingleProject>true</SingleProject>
    <ImplicitUsings>enable</ImplicitUsings>
    <!-- Display name -->
    <ApplicationTitle>Tendrils</ApplicationTitle>
    <!-- App Identifier -->
    <ApplicationId>com.tendrils</ApplicationId>
    <!-- Versions -->
    <ApplicationDisplayVersion>1.0</ApplicationDisplayVersion>
    <ApplicationVersion>1</ApplicationVersion>
    <!-- Required for C# Hot Reload -->
    <UseInterpreter Condition="'$(Configuration)' == 'Debug'">True</UseInterpreter>
    <SupportedOSPlatformVersion Condition="$([MSBuild]::GetTargetPlatformIdentifier('$(TargetFramework)')) == 'ios'">14.2</SupportedOSPlatformVersion>
    <SupportedOSPlatformVersion Condition="$([MSBuild]::GetTargetPlatformIdentifier('$(TargetFramework)')) == 'android'">28.0</SupportedOSPlatformVersion>
  </PropertyGroup>
  	<PropertyGroup Condition="'$(Configuration)|$(TargetFramework)|$(Platform)'=='Debug|net8.0-ios|AnyCPU'">
		<ForceSimulatorX64ArchitectureInIDE>true</ForceSimulatorX64ArchitectureInIDE>
	</PropertyGroup>
  <PropertyGroup Condition="'$(Configuration)' == 'Debug'">
    <EmbedAssembliesIntoApk>true</EmbedAssembliesIntoApk>
    <!--<UseInterpreter>false</UseInterpreter>-->
    <_MauiForceXamlCForDebug>true</_MauiForceXamlCForDebug>
  </PropertyGroup>
  <PropertyGroup Condition="'$(Configuration)|$(TargetFramework)|$(Platform)'=='Debug|net8.0-ios|AnyCPU'">
    <CreatePackage>false</CreatePackage>
    <MtouchUseLlvm>True</MtouchUseLlvm>
  </PropertyGroup>
  <PropertyGroup Condition="'$(Configuration)|$(TargetFramework)|$(Platform)'=='Release|net8.0-ios|AnyCPU'">
    <CreatePackage>false</CreatePackage>
    <MtouchLink>SdkOnly</MtouchLink>
  </PropertyGroup>
  <PropertyGroup Condition="'$(Configuration)|$(TargetFramework)|$(Platform)'=='Debug|net8.0-android34.0|AnyCPU'">
    <EmbedAssembliesIntoApk>True</EmbedAssembliesIntoApk>
  </PropertyGroup>
  <PropertyGroup Condition="'$(Configuration)|$(TargetFramework)|$(Platform)'=='Debug|net8.0-android|AnyCPU'">
    <EmbedAssembliesIntoApk>False</EmbedAssembliesIntoApk>
  </PropertyGroup>
  <PropertyGroup Condition="'$(TargetFramework)'=='net8.0-ios'">
    <CodesignKey>Apple Development: Created via API (27L59SNA97)</CodesignKey>
    <CodesignProvision>VS: com.trellise.tendrl Development</CodesignProvision>
  </PropertyGroup> 
  <ItemGroup>
    <!-- App Icon -->
    <MauiIcon Include="Resources\AppIcon\appicon.svg" ForegroundFile="Resources\AppIcon\appicon2.svg" ForegroundScale="0.50" />
    <!-- Splash Screen -->
     <MauiSplashScreen Include="Resources\Splash\splash.svg" Color="#3F75FF" />
    <!-- Images -->
    <MauiImage Include="Resources\Images\*" />
    <MauiImage Include="Resources\Images\TabIcons\*" BaseSize="28,28" />
    <!-- Custom Fonts -->
    <MauiFont Include="Resources\Fonts\*" />
    <!-- Raw Assets (also remove the "Resources\Raw" prefix) -->
    <MauiAsset Include="Resources\Raw\**" LogicalName="%(RecursiveDir)%(Filename)%(Extension)" />
    <MauiImage Include="Resources\Images\SocialMediaLogos\*" />
  </ItemGroup>
  <ItemGroup>
    <Compile Remove="Resources\NewFolder\**" />
    <EmbeddedResource Remove="Resources\NewFolder\**" />
    <MauiCss Remove="Resources\NewFolder\**" />
    <MauiXaml Remove="Resources\NewFolder\**" />
    <None Remove="Resources\NewFolder\**" />
  </ItemGroup>
  <ItemGroup>
    <AndroidAsset Remove="Platforms\Android\Assets\tendrils.ttf" />
  </ItemGroup>
  <ItemGroup>
    <None Remove="GrialLicense" />  
    <None Remove="Platforms\iOS\Resources\tendrils.ttf" />  
  </ItemGroup>
<ItemGroup Condition="'$(TargetFramework)' == 'net8.0-android'">
  <GoogleServicesJson Include="Platforms\Android\google-services.json" />
</ItemGroup>
  <ItemGroup>
    <EmbeddedResource Include="GrialLicense" />
  </ItemGroup>  
  <ItemGroup>
    <PackageReference Include="AiForms.Maui.SettingsView" Version="1.0.16" />
    <PackageReference Include="Azure.Storage.Blobs" Version="12.23.0" />
    <PackageReference Include="Azure.Storage.Common" Version="12.22.0" />
    <PackageReference Include="Microsoft.AppCenter" Version="5.0.6" />
    <PackageReference Include="Microsoft.AppCenter.Analytics" Version="5.0.6" />
    <PackageReference Include="Microsoft.AppCenter.Crashes" Version="5.0.6" />
    <PackageReference Include="Microsoft.AspNet.SignalR.Client" Version="2.4.3" />
    <PackageReference Include="Microsoft.Graph" Version="5.67.0" />
    <PackageReference Include="Microsoft.Identity.Client" Version="4.66.2" />
    <PackageReference Include="Microsoft.Maui.Controls" Version="8.0.82" />
    <PackageReference Include="Microsoft.Maui.Controls.Compatibility" Version="8.0.82" />
    <PackageReference Include="Mopups" Version="1.3.2" />
    <PackageReference Include="CommunityToolkit.Maui" Version="9.0.1" />
    <PackageReference Include="Plugin.MauiMTAdmob" Version="1.7.1" />
    <PackageReference Include="sqlite-net-pcl" Version="1.9.172" />
    <PackageReference Include="System.Net.Http" Version="4.3.4" />
    <PackageReference Include="System.Text.RegularExpressions" Version="4.3.1" />
    <PackageReference Include="UXDivers.GrialMaui" Version="4.2.117" />
    <PackageReference Include="UXDivers.GrialMaui.Maps" Version="4.2.114" />
    <PackageReference Include="WindowsAzure.MobileServices" Version="1.3.2" />
  </ItemGroup>
  <ItemGroup>   
    <Page Include="Resources\AppIcon\appicon.svg">
      <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
    </Page>
  </ItemGroup>
  <ItemGroup>
    <EmbeddedResource Update="Resx\AppResources.resx">
      <Generator>PublicResXFileCodeGenerator</Generator>
      <LastGenOutput>AppResources.Designer.cs</LastGenOutput>
    </EmbeddedResource>
  </ItemGroup>
  <ItemGroup>
    <Compile Update="Resx\AppResources.Designer.cs">
      <DependentUpon>AppResources.resx</DependentUpon>
    </Compile>
  </ItemGroup>
  <ItemGroup Condition="'$(TargetFramework)' == 'net8.0-android34.0'">
    <PackageReference Include="Xamarin.Firebase.Messaging">
      <Version>124.1.0</Version>
    </PackageReference>
  </ItemGroup>
  <ItemGroup>
    <Folder Include="Platforms\Android\Renderers\" />
  </ItemGroup>
  <ItemGroup Condition="'$(TargetFramework)' == 'net8.0-android'">
    <PackageReference Include="Xamarin.Firebase.Messaging">
      <Version>124.1.0</Version>
    </PackageReference>
  </ItemGroup>
  <ItemGroup>
    <MauiFont Include="Platforms\Android\Assets\tendrils.ttf" />
    <MauiFont Include="Platforms\iOS\Resources\tendrils.ttf" />
  </ItemGroup>
</Project>

Steps to Reproduce

  1. Using Visual Studio 2022 create a new .NET MAUI app
  2. Follow the tutorial here to enable notifications
  3. Run the app targeting Android 14 - API 34
  4. Observe the following runtime error: Java.Lang.IllegalStateException: 'Default FirebaseApp is not initialized in this process com.tendrils. Make sure to call FirebaseApp.initializeApp(Context) first.'

Did you find any workaround?

No response

Relevant log output

10:57:49:289	[mono-rt] 	at com.google.firebase.FirebaseApp.getInstance(FirebaseApp.java:179)
10:57:49:289	[mono-rt] 	at com.google.firebase.messaging.FirebaseMessaging.getInstance(FirebaseMessaging.java:120)
10:57:49:289	[mono-rt] 	at crc6487f8e260309c87d5.MainActivity.n_onCreate(Native Method)
10:57:49:289	[mono-rt] 	at crc6487f8e260309c87d5.MainActivity.onCreate(MainActivity.java:44)
10:57:49:289	[mono-rt] 	at android.app.Activity.performCreate(Activity.java:8595)
10:57:49:289	[mono-rt] 	at android.app.Activity.performCreate(Activity.java:8573)
10:57:49:289	[mono-rt] 	at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1456)
10:57:49:347	[mono-rt] 	at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:3764)
10:57:49:347	[mono-rt] 	at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3922)
10:57:49:347	[mono-rt] 	at android.app.servertransaction.LaunchActivityItem.execute(LaunchActivityItem.java:103)
10:57:49:347	[mono-rt] 	at android.app.servertransaction.TransactionExecutor.executeCallbacks(TransactionExecutor.java:139)
10:57:49:347	[mono-rt] 	at android.app.servertransaction.TransactionExecutor.execute(TransactionExecutor.java:96)
10:57:49:347	[mono-rt] 	at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2443)
10:57:49:347	[mono-rt] 	at android.os.Handler.dispatchMessage(Handler.java:106)
10:57:49:347	[mono-rt] 	at android.os.Looper.loopOnce(Looper.java:205)
10:57:49:347	[mono-rt] 	at android.os.Looper.loop(Looper.java:294)
10:57:49:347	[mono-rt] 	at android.app.ActivityThread.main(ActivityThread.java:8177)
10:57:49:347	[mono-rt] 	at java.lang.reflect.Method.invoke(Native Method)
10:57:49:349	[mono-rt] 	at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:552)
10:57:49:349	[mono-rt] 	at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:971)
10:57:49:349	[mono-rt]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant