Need help > FirebasePushNotificationsPlugin : Default FirebaseApp is not initialized in this process - c#

I use the FirebasePushNotificationsPlugin in my Xamarin Forms project (4.7) to have the push notifications in my project.
I updated to the latest version (3.3.10) but now I get this error on Android (working on iOS):
**Java.Lang.IllegalStateException:** 'Default FirebaseApp is not initialized
in this process com.companyname.firebasetest.
Make sure to call FirebaseApp.initializeApp(Context) first.'
I found some solutions that does not work for me:
My google-services.json has the GoogleServicesJson build action
My firebase android app package name is the same package name on my Android project.
I tried to update android's tools
Also tried to add this line:
FirebaseApp app = FirebaseApp.InitializeApp(Android.App.Application.Context);
PS:
I created a new project (and new firebase project) but I get the same error
I pulled the sample of the FirebasePushNotification Plugin, and still getting the error
Notifications was working with version 2.3.x
What can I do ? I need help
Thx guys

Related

Xamarin.UITesting NU1201 Error: Android 8.1 Is incompatible with .NETFramework 4.6.1

Have been having a little issue for the last couple of days now where I will create a new Xamarin Forms project on Visual Studio 2017 and add a Xamarin.UITest Cross-Platform Test Project for unit testing I recieve a series of NU1201 Errors when I reference the .Android App in the UITest Project.
Here is the exact error i get:
Error NU1201 Project App1.Android is not compatible with net461 (.NETFramework,Version=v4.6.1) / win-x64. Project App1.Android supports: monoandroid81 (MonoAndroid,Version=v8.1)
I have played around with the Android version numbers to see if the UITesting package doesnt support the latest android but no matter what version of android i target the problem remains the same.
Here is a screenshot of the project.
All the code is unchanged from the default project and runs in the simulator fine but only produces these errors when the Android app is referenced to the UITest project.
Solved it after many more hours of testing and trialling. Instead of adding the Android project to the references, Within the AppInitializer I added another method to the StartApp() call like so:
public class AppInitializer
{
public static IApp StartApp(Platform platform)
{
if (platform == Platform.Android)
{
return ConfigureApp.Android.InstalledApp("com.companyname.App1").StartApp();
}
return ConfigureApp.iOS.StartApp();
}
}
Therefore once I had already run the app via the emulator for the first time and installed on the device, the UITest simply uses the installed APK on the emulator instead of the project.
For those who ran into error NU1201, you might have come to the right place. This may not apply to the question asked but I ran into error NU1201 the other day and the reason for that is the nuproj configuration file for our nuget project has target configuration wrong. It should have been
<TargetFrameworkVersion>v4.6.2</TargetFrameworkVersion>
instead of
<TargetFramework>net462</TargetFramework>
because the project is not of "SDK-style."
References: https://learn.microsoft.com/en-us/visualstudio/msbuild/msbuild-target-framework-and-target-platform?view=vs-2019

How to use iOS simulator/Android simulator from visual studio for Mac with xamarian.forms

I made mobile app at azure and quickstarted it as xamarian.forms and (after failing to publish downloaded table api application and deciding to edit it in browser) downloaded the client application they provided. Then when I tried to launch it with on (Debug>IPhone 8 Plus iOS 11.2) simulator, it (simulator) started but no application is visible (and nothing unusual is installed).
It shows warnings (could it be relevant?):
Warning MSB3276: Found conflicts between different versions of the same dependent assembly. Please set the "AutoGenerateBindingRedirects" property to true in the project file. For more information, see http://go.microsoft.com/fwlink/?LinkId=294190. (MSB3276)
(For Android simulator it gives some error like:
/Library/Frameworks/Mono.framework/Versions/5.4.1/lib/mono/xbuild/Microsoft/NuGet/Microsoft.NuGet.targets(5,5): Error: Your project is not referencing the "MonoAndroid,Version=v8.0" framework. Add a reference to "MonoAndroid,Version=v8.0" in the "frameworks" section of your project.json, and then re-run NuGet restore.
)
How can I see the ****** application?
Thank you. =)
Open the project.json file in your xxx.Droid project. Change the MonoAndroid version from:
"frameworks": {
"MonoAndroid,Version=v7.1": {}
}
to:
"frameworks": {
"MonoAndroid,Version=v8.0": {}
}
Now, Restore Nuget Packages for your solution.

Xamarin android app crashes once its uploaded to google play store

I recently developed an android app in Visual Studio with Xamarin and I'm able to open the app when downloading the release apk to my phone, but once I uploaded it to the google play store and try to download it and then open it crashes. And the crash log displays this error below:
java.lang.RuntimeException:
at com.android.internal.os.ZygoteInit.main (ZygoteInit.java:1410)
Caused by: java.lang.reflect.InvocationTargetException:
at java.lang.reflect.Method.invoke (Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run (ZygoteInit.java:1520)
at md5d38b484f2053706449e9bb7e84aa7c74.HomeFragment.n_onCreateView (Native Method)
at md5d38b484f2053706449e9bb7e84aa7c74.HomeFragment.onCreateView (HomeFragment.java:38)
at android.app.Fragment.performCreateView (Fragment.java:2352)
at android.app.FragmentManagerImpl.moveToState (FragmentManager.java:995)
at android.app.FragmentManagerImpl.moveToState (FragmentManager.java:1171)
at android.app.BackStackRecord.run (BackStackRecord.java:815)
at android.app.FragmentManagerImpl.execPendingActions (FragmentManager.java:1582)
at android.app.FragmentManagerImpl$1.run (FragmentManager.java:483)
at android.os.Handler.handleCallback (Handler.java:751)
at android.os.Handler.dispatchMessage (Handler.java:95)
at android.os.Looper.loop (Looper.java:154)
at android.app.ActivityThread.main (ActivityThread.java:6682)
What am I doing wrong? Is there a way to get a more verbose crash log?
The OnCreateView that the log is referencing is trying to get access to a PCL that has functions for hitting a remote api to get data from. Could this be the issue? The PCL is referenced via dll in the android app's project but is there something else I needed to do?
UPDATE
I'm seeing tons of responses related to this stating that is a bug with Xamarin but I'm not understanding exactly code-wise what I need to do to fix it.

Xamarin Push Notifications Build Error

I am implementing push notifications within an application using the Azure Messaging component from Xamarin - iOS only.
I have been able to successfully build, deploy to a device, and test
locally.
The component is installed using the Nuget package for the component.
However, when I check the changes into source control and try to
build on our build server
I receive the following error message:
MTOUCH: error MT1304: The embedded framework
'WindowsAzureMessaging.framework' in
/Users/Clinician/TeamCity/buildAgent/work/b535d319c25da2ee/Frameworks
/packages/Xamarin.Azure.NotificationHubs.iOS.1.2.5.2/lib/Xamarin.iOS10/Xamarin.Azure.NotificationHubs.iOS.dll
is invalid: it does not contain an Info.plist.
I haven't been able to find a lot of information about the MT1304 error.
Has anyone else encountered this or have any suggestions on how to resolve?

Can't add Google Play Services to Xamarin Android Project

I have been trying to add Xamarin Google Play Services Binding to my project so that I can add admob ads to my app.
I went and installed the Nuget package, "Xamarin Google Play Services Binding"
But then when I try to run (even if I make no other changes) I get 100+ errors about packages not existing:
For example:
Error 31 package android.support.v4.app does not exist
private native void n_onTabReselected (android.support.v7.app.ActionBar.Tab p0, android.support.v4.app.FragmentTransaction p1);
and:
Error 77 package com.google.ads.mediation does not exist
private native void n_onReceivedAd (com.google.ads.mediation.MediationInterstitialAdapter p0);
When I then go to the file I find at the top the package name is the one that claims doesn't exist, but with 'mono' attached to the front. So for example on this last error it claims that package "com.google.ads.mediation" does not exist, at the top the package itself says "package mono.com.google.ads.mediation;"
I am very new to using Xamarin and I am pulling my hair out trying to get this fixed so I would desperately appreciate any help or advice.
Try installing Google Play Services as a components instead of a Nuget Reference
http://developer.xamarin.com/guides/cross-platform/application_fundamentals/components_walkthrough/

Categories