Я реализовал приведенный ниже код в двух проектах, один работает, а другой не работает, ниже приведен код.я проверил другие сообщения, которые говорят, что использовать com.google.gms:google-services
я добавил Xamarin.GooglePlayServices.basement
все еще он выдает ошибку, какой плагин GooglePlayServices я должен использовать для Xamarin?
protected override void OnCreate(Bundle savedInstanceState)
{
base.OnCreate(savedInstanceState);
SetContentView(Resource.Layout.activity_main);
Firebase.FirebaseApp.InitializeApp(this);
Plugin.CurrentActivity.CrossCurrentActivity.Current.Activity = this;
buttonView = FindViewById<Button>(Resource.Id.button1);
error = FindViewById<TextView>(Resource.Id.error);
buttonView.Click += StartQueryDetailsAsync;
}
public async void StartQueryDetailsAsync(object sender, EventArgs e)
{
Dictionary<string, Java.Lang.Object> user = new Dictionary<string, Java.Lang.Object>
{
{ "PurchaseToken", purchase.PurchaseToken },
{ "QueryNumber", 1}
};
firestore = FirebaseFirestore.Instance;
firestore.Collection("DineUser").Document(purchase.Id).Set(user).AddOnSuccessListener(this);
}
Ошибка:
{Java.Lang.IllegalArgumentException: FirebaseOptions.getProjectId() cannot be null at Java.Interop.JniEnvironment+StaticMethods.CallStaticObjectMethod (Java.Interop.JniObjectReference type, Java.Interop.JniMethodInfo method) [0x00068] in <8acc8089c2ed40d08469fbaa6710a44c>:0 at Android.Runtime.JNIEnv.CallStaticObjectMethod (System.IntPtr jclass, System.IntPtr jmethod) [0x0000e] in <957bbfdfda4341e2939c881206c1140a>:0 at Firebase.Firestore.FirebaseFirestore.get_Instance () [0x0002f] in <97744bd4f3f740c1884b76e44794b938>:0 at DineCam.Main.DrawRect+<Purchase>d__56.MoveNext () [0x00417] in D:\DineCam\DineCam\Main\DrawRect.cs:427 --- End of managed Java.Lang.IllegalArgumentException stack trace --- java.lang.IllegalArgumentException: FirebaseOptions.getProjectId() cannot be null at com.google.firebase.firestore.FirebaseFirestore.zze(Unknown Source) at com.google.firebase.firestore.FirebaseFirestore.getInstance(Unknown Source) at md580a1eddd40074c89f21a5ec99d8b044c.DrawRect.n_onActivityResult(Native Method) at md580a1eddd40074c89f21a5ec99d8b044c.DrawRect.onActivityResult(DrawRect.java:86) at android.app.Activity.dispatchActivityResult(Activity.java:6508) at android.app.ActivityThread.deliverResults(ActivityThread.java:3925) at android.app.ActivityThread.handleSendResult(ActivityThread.java:3972) at android.app.ActivityThread.-wrap16(ActivityThread.java) at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1537) at android.os.Handler.dispatchMessage(Handler.java:111) at android.os.Looper.loop(Looper.java:207) at android.app.ActivityThread.main(ActivityThread.java:5728) at java.lang.reflect.Method.invoke(Native Method) at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:789) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:679) }