Open stavroaudi opened 5 years ago
Same here!
Have you Initialized FirebaseApp by calling
FirebaseApp.InitializeApp(Application.Context);
Have you Initialized FirebaseApp by calling
FirebaseApp.InitializeApp(Application.Context);
It is expected to occur when the Plugin.CloudFirestore.CloudFirestore.Init();
is called.
public static void Init(Context context)
{
try
{
Firebase.FirebaseApp.GetInstance(DefaultAppName);
}
catch (Exception)
{
var baseOptions = Firebase.FirebaseOptions.FromResource(context);
var options = new Firebase.FirebaseOptions.Builder(baseOptions).SetProjectId(baseOptions.StorageBucket.Split('.')[0]).Build();
Firebase.FirebaseApp.InitializeApp(context, options, DefaultAppName);
}
}
Having a similar issue. When initializing I keep receiving a null reference: Java.Lang.NullPointerException: Attempt to read from field 'java.lang.String com.google.firebase.FirebaseOptions.zzehy' on a null object reference
If I initialize FirebaseApp manually, and try to make any calls, I get an illegal app name exception:
{Java.Lang.IllegalStateException: FirebaseApp with name [FirebasePlugin] doesn't exist. Available app names: Our Pantry
at Java.Interop.JniEnvironment+StaticMethods.CallStaticObjectMethod (Java.Interop.JniObjectReference type, Java.Interop.JniMethodInfo method, Java.Interop.JniArgumentValue args) [0x00069] in <42dc777b518744fdae9988e94489a4a0>:0
at Android.Runtime.JNIEnv.CallStaticObjectMethod (System.IntPtr jclass, System.IntPtr jmethod, Android.Runtime.JValue parms) [0x00000] in /Users/builder/data/lanes/6102/8255f42f/source/monodroid/external/xamarin-android/src/Mono.Android/Android.Runtime/JNIEnv.g.cs:562
at Firebase.FirebaseApp.GetInstance (System.String name) [0x0004e] in <9eb73a399f94426da0a6f6162f59beed>:0
at Plugin.CloudFirestore.CloudFirestoreImplementation.get_Instance () [0x00000] in /Users/f-matsushima/Plugin.CloudFirestore/Plugin.CloudFirestore.Android/CloudFirestoreImplementation.cs:13
at OurPantry.Droid.RecipeStorageAndroid.get_Firestore () [0x00000] in C:\Users\james\source\repos\OurPantry\OurPantry\OurPantry.Android\RecipeStorage.cs:24
at OurPantry.Droid.RecipeStorageAndroid+
Have you Initialized FirebaseApp by calling FirebaseApp.InitializeApp(Application.Context);
It is expected to occur when the
Plugin.CloudFirestore.CloudFirestore.Init();
is called.public static void Init(Context context) { try { Firebase.FirebaseApp.GetInstance(DefaultAppName); } catch (Exception) { var baseOptions = Firebase.FirebaseOptions.FromResource(context); var options = new Firebase.FirebaseOptions.Builder(baseOptions).SetProjectId(baseOptions.StorageBucket.Split('.')[0]).Build(); Firebase.FirebaseApp.InitializeApp(context, options, DefaultAppName); } }
Adding Plugin.CloudFirestore.CloudFirestore.Init();
isn't included in the setup instructions for Android for this project but it is necessary. Thank you.
I have installed Plugin.CloudFirestore and Xamarin.Firebase.Firestore, but I cannot initialize CloudFirestore on Android's mainactivity.cs
Plugin.CloudFirestore.CloudFirestore.Init();
Gives an error saying that CloudFirestore does not exist in Plugin.CloudFirestore
I'm facing the same issue, is there a workaround or something? I already installed everything and followed the tutorial.
As per CatalinPrata's update the initialisation step on Android that works is:
Plugin.CloudFirestore.CloudFirestore.Init(Application.Context);
@simondotm Sorry, but Plugin.CloudFirestore.CloudFirestore does not exist in Plugin.CloudFirestore v2.0.0 If I add the line in my MainActivity in my android project, the project WON'T COMPILE!
The Plugin.CloudFirestore is listed under References. Is something missing?
@simondotm Sorry, but Plugin.CloudFirestore.CloudFirestore does not exist in Plugin.CloudFirestore v2.0.0 If I add the line in my MainActivity in my android project, the project WON'T COMPILE!
The Plugin.CloudFirestore is listed under References. Is something missing?
Ah my bad, I'm using v1.2.3 package, not the latest. 2.x
I found a workaround for this adding:
FirebaseFirestore firestore = FirebaseFirestore.GetInstance(Firebase.FirebaseApp.Instance); FirebaseFirestoreSettings settings = new FirebaseFirestoreSettings.Builder().SetTimestampsInSnapshotsEnabled(true).Build(); firestore.FirestoreSettings = settings;
inside OnCreate method at MainActivity.cs.
I'm using version 2.0.0-pre1 and VS for MAC. Make sure you also add the plugin to Android project. This is how it looks:
@arturo1212 Not working in 2.0.0. I get the following error: Java.Lang.IllegalStateException: 'Default FirebaseApp is not initialized in this process com.companyname.MyApp. Make sure to call FirebaseApp.initializeApp(Context) first.'
is there any fix for this yet? I'm still unable to open my project on android...
@DannyTimms I'm able to use it without issue. Do you have an error message and implementation code?
is there any fix for this yet? I'm still unable to open my project on android...
@DannyTimms I thought I better reply because I had the same problem and it was driving me insane. You just have to make sure you have a google-services.json file set in your android project, it's build action need to be GoogleServicesJson,
but most importantly, you must have set your package name to on that's in your google-services.json file (and in your firestore console), otherwise you get that error
@DannyTimms you can also manually initialize it, by manually openning your google-services.json file and copy pasting the info here:
FirebaseFirestore database;
var options = new FirebaseOptions.Builder() .SetProjectId("--") .SetApplicationId("--") .SetApiKey("--") .SetDatabaseUrl("--") .SetStorageBucket("--") .Build();
var app = FirebaseApp.InitializeApp(this, options);
database = FirebaseFirestore.GetInstance(app);
make sure you have using Firebase.Firestore; at the top of mainactivity.cs
I have the plugin.cloud Firestore and the Xamarin.Firebase.Firestore installed alongside my google-services.json build set to GoogleServicesJson and have FirebaseApp.InitializeApp(Application Context) and still getting java.exe exited with a code 2 error. Any suggestions
Sorry for necroing this issue but I was having this same problem using Xamarin Forms. My steps to solve:
I have had a bad time treating to initialize Android project. Finally, I found out the package name from google-services.json and android project were different. Following the instructions and making sure the package names are equals worked for me. Using:
I have installed Plugin.CloudFirestore and Xamarin.Firebase.Firestore, but I cannot initialize CloudFirestore on Android's mainactivity.cs
Plugin.CloudFirestore.CloudFirestore.Init();
Gives an error saying that CloudFirestore does not exist in Plugin.CloudFirestore