我正在尝试获取Cloud Firestore数据库的参考,但出现以下错误
Java.Lang.NoClassDefFoundError:无法解决以下问题:Lcom / google / common / base / Preconditions;
我已经阅读了所有文档,并检查了一切。
以下是包裹清单
Xamarin.Android.Support.Design {28.0.0.1}
Xamarin.Firebase.Firestore {71.1705.0}
Xamarin.Google.Guava {27.1.0.2}
这是我的GetDatabase方法
public FirebaseFirestore GetDatabase()
{
FirebaseFirestore data_base;
var app = FirebaseApp.InitializeApp(Application.Context);
if (app == null)
{
var options = new FirebaseOptions.Builder()
.SetProjectId("deliveryapp-254615")
.SetApplicationId("deliveryapp-254615")
.SetApiKey("AIzaSyD9HOqiYHFLsT4RspeZyElbhhqq5tNBXPs")
.SetDatabaseUrl("https://deliveryapp-254615.firebaseio.com")
.SetStorageBucket("deliveryapp-254615.appspot.com")
.Build();
app = FirebaseApp.InitializeApp(Application.Context, options);
}
data_base = FirebaseFirestore.GetInstance(app);
return data_base
}
以下是调试日志
10-03 19:08:39.154 D/FirebaseApp(28559): com.google.firebase.iid.FirebaseInstanceId is not linked. Skipping initialization.
10-03 19:08:39.155 D/FirebaseApp(28559): com.google.firebase.crash.FirebaseCrash is not linked. Skipping initialization.
10-03 19:08:39.156 D/FirebaseApp(28559): com.google.android.gms.measurement.AppMeasurement is not linked. Skipping initialization.
10-03 19:08:39.180 I/zygote (28559): Rejecting re-init on previously-failed class java.lang.Class<com.google.firebase.firestore.FirebaseFirestore$2>: java.lang.NoClassDefFoundError: Failed resolution of: Lcom/google/common/base/Function;
10-03 19:08:39.180 I/zygote (28559): at void mono.android.view.View_OnClickListenerImplementor.n_onClick(android.view.View) (View_OnClickListenerImplementor.java:-2)
10-03 19:08:39.180 I/zygote (28559): at void mono.android.view.View_OnClickListenerImplementor.onClick(android.view.View) (View_OnClickListenerImplementor.java:30)
10-03 19:08:39.180 I/zygote (28559): at boolean android.view.View.performClick() (View.java:6297)
10-03 19:08:39.180 I/zygote (28559): at void android.view.View$PerformClick.run() (View.java:24797)
10-03 19:08:39.180 I/zygote (28559): at void android.os.Handler.handleCallback(android.os.Message) (Handler.java:790)
10-03 19:08:39.180 I/zygote (28559): at void android.os.Handler.dispatchMessage(android.os.Message) (Handler.java:99)
10-03 19:08:39.180 I/zygote (28559): at void android.os.Looper.loop() (Looper.java:164)
10-03 19:08:39.180 I/zygote (28559): at void android.app.ActivityThread.main(java.lang.String[]) (ActivityThread.java:6626)
10-03 19:08:39.180 I/zygote (28559): at java.lang.Object java.lang.reflect.Method.invoke(java.lang.Object, java.lang.Object[]) (Method.java:-2)
10-03 19:08:39.180 I/zygote (28559): at void com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run() (RuntimeInit.java:438)
10-03 19:08:39.180 I/zygote (28559): at void com.android.internal.os.ZygoteInit.main(java.lang.String[]) (ZygoteInit.java:811)
10-03 19:08:39.180 I/zygote (28559): Caused by: java.lang.ClassNotFoundException: Didn't find class "com.google.common.base.Function" on path: DexPathList[[zip file "/data/app/com.Voidron.Delivery_DemoApp-d9Ckk53XN-uid0HuJbaR0A==/base.apk"],nativeLibraryDirectories=[/data/app/com.Voidron.Delivery_DemoApp-d9Ckk53XN-uid0HuJbaR0A==/lib/arm, /data/app/com.Voidron.Delivery_DemoApp-d9Ckk53XN-uid0HuJbaR0A==/base.apk!/lib/armeabi-v7a, /system/lib, /system/vendor/lib]]
10-03 19:08:39.180 I/zygote (28559): at java.lang.Class dalvik.system.BaseDexClassLoader.findClass(java.lang.String) (BaseDexClassLoader.java:125)
10-03 19:08:39.180 I/zygote (28559): at java.lang.Class java.lang.ClassLoader.loadClass(java.lang.String, boolean) (ClassLoader.java:379)
10-03 19:08:39.180 I/zygote (28559): at java.lang.Class java.lang.ClassLoader.loadClass(java.lang.String) (ClassLoader.java:312)
答案 0 :(得分:0)
我设法使用https://github.com/xamarin/GooglePlayServicesComponents/issues/258
的输入来解决这个问题我所做的只是将番石榴的包装降级为27.1.0.0,这似乎可以解决问题