Closed aspepper closed 1 month ago
I managed to resolve the issue with initializing Firebase in my Avalonia Cross Platform project for Android.
The problem was that the package name entered during the "Add Firebase to your Android app" step in the Firebase Console did not match the namespace of my application. Initially, I used the default package name (e.g., com.company.appname
), but my application had a namespace like <ApplicationId>AppUsingPushNotify.Android</ApplicationId>
.
By updating the package name in the Firebase Console to match my application's namespace (AppUsingPushNotify.Android
), the google-services.json
file was generated with the correct package name: "package_name": "AppUsingPushNotify.Android"
.
After making this change, Firebase initialized successfully when I ran the application.
Here is the corrected setup in my AvaloniaApp.Android.csproj
:
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net8.0-android</TargetFramework>
<SupportedOSPlatformVersion>21</SupportedOSPlatformVersion>
<Nullable>enable</Nullable>
<ApplicationId>AppUsingPushNotify.Android</ApplicationId>
<ApplicationVersion>1</ApplicationVersion>
<ApplicationDisplayVersion>1.0</ApplicationDisplayVersion>
<AndroidPackageFormat>apk</AndroidPackageFormat>
<AndroidEnableProfiledAot>False</AndroidEnableProfiledAot>
</PropertyGroup>
<ItemGroup>
<None Remove="google-services.json" />
<None Remove="Resources\drawable\ic_stat_ic_notification.png" />
</ItemGroup>
<ItemGroup>
<AndroidResource Include="Icon.png">
<Link>Resources\drawable\Icon.png</Link>
</AndroidResource>
</ItemGroup>
<ItemGroup>
<GoogleServicesJson Include="google-services.json" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="Avalonia.Android" Version="11.0.11" />
<PackageReference Include="FirebaseAdmin" Version="3.0.0" />
<PackageReference Include="Xamarin.AndroidX.Core.SplashScreen" Version="1.0.1.9" />
<PackageReference Include="Xamarin.Firebase.Core" Version="121.1.1.9" />
<PackageReference Include="Xamarin.Firebase.Messaging" Version="124.0.0" />
<PackageReference Include="Xamarin.Google.Dagger" Version="2.50.0" />
<PackageReference Include="Xamarin.GooglePlayServices.Base" Version="118.4.0" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\AppUsingPushNotify\AppUsingPushNotify.csproj" />
</ItemGroup>
<ItemGroup>
<None Update="appavaloniatestepushnotify-firebase-adminsdk-dz9zz-390c2557fc.json">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
</ItemGroup>
</Project>
I hope this helps anyone facing a similar issue.
Thank you for your assistance!
Hello everyone,
I'm currently working on an Avalonia Cross Platform project for Android and I'm trying to configure Firebase Cloud Messaging (FCM) to receive push notifications. However, I'm encountering an issue where the default
FirebaseApp
fails to initialize. Below are the details of my setup, including the code I've implemented and the error message I'm receiving.Project File:
AvaloniaApp.Android.csproj
MainActivity.cs
FirebaseService.cs
AndroidManifest.xml
Error Message
When I run the project, I receive the following error message in the output debug:
Problem Description
It seems that the
FirebaseApp
is not being initialized properly due to missing default options. I've ensured that thegoogle-services.json
file is included in the project and is being copied to the correct location during the build process. However, I'm still encountering this issue.Could anyone provide guidance on what might be wrong with my setup or what additional configuration steps I need to take to resolve this issue?
Thank you in advance for your help!