我有一个Xamarin.Android应用,正在尝试连接到Firestore。
我正在创建Firestore实例
FirebaseFirestore GetInst()
{
var baseOptions = Firebase.FirebaseOptions.FromResource(context);
var options = new Firebase.FirebaseOptions.Builder(baseOptions).SetProjectId(baseOptions.StorageBucket.Split('.')[0]).Build();
var app = Firebase.FirebaseApp.InitializeApp(context, options, AppName);
return FirebaseFirestore.GetInstance(app);
}
现在,当尝试在MainActivity中创建DocumentReference时
protected override void OnCreate(Bundle savedInstanceState)
{
base.OnCreate(savedInstanceState);
SetContentView(Resource.Layout.activity_main);
//body
docRef = GetInst().Document("sampleData/samples");
}
上面的异常引发于GetInst().Document()
。
我找不到Xamarin和Firestore特有的东西,也无法调试,因为它是外部Java代码...
Logcat
AndroidRuntime FATAL EXCEPTION: main
AndroidRuntime java.lang.RuntimeException: Internal error in Firestore (0.6.6-dev).
at com.google.android.gms.internal.zzejs.run(Unknown Source:21)
at android.os.Handler.handleCallback(Handler.java:790)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:164)
at android.app.ActivityThread.main(ActivityThread.java:6494)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:438)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:807)
AndroidRuntime Caused by: java.lang.NoClassDefFoundError: Failed resolution of: Lcom/google/common/base/Preconditions;
at io.grpc.zzbm.<init>(Unknown Source:5)
at io.grpc.zzbm.<init>(Unknown Source:0)
at io.grpc.zzbi.<init>(Unknown Source:1)
at io.grpc.zzbi.<init>(Unknown Source:0)
at io.grpc.zzbm.zza(Unknown Source:3)
at io.grpc.internal.GrpcUtil.<clinit>(Unknown Source:42)
at io.grpc.internal.AbstractManagedChannelImplBuilder.<clinit>(Unknown Source:20)
at io.grpc.okhttp.zzp.zzty(Unknown Source:0)
at io.grpc.okhttp.OkHttpChannelProvider.zztt(Unknown Source:0)
at io.grpc.zzbc.forTarget(Unknown Source:4)
at com.google.android.gms.internal.zzeid.<init>(Unknown Source:22)
at com.google.android.gms.internal.zzeca.zza(Unknown Source:74)
at com.google.android.gms.internal.zzecc.run(Unknown Source:8)
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:457)
at java.util.concurrent.FutureTask.run(FutureTask.java:266)
at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:301)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1162)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:636)
at com.google.android.gms.internal.zzejp$zza.run(Unknown Source:7)
at java.lang.Thread.run(Thread.java:764)
AndroidRuntime Caused by: java.lang.ClassNotFoundException: Didn't find class "com.google.common.base.Preconditions" on path: DexPathList[[zip file "/data/app/com.gogreenordietryin.mytem-cIxZrIRJzpVFvHHZ8Ok9SQ==/base.apk"],nativeLibraryDirectories=[/data/app/com.gogreenordietryin.mytem-cIxZrIRJzpVFvHHZ8Ok9SQ==/lib/x86, /data/app/com.gogreenordietryin.mytem-cIxZrIRJzpVFvHHZ8Ok9SQ==/base.apk!/lib/x86, /system/lib, /vendor/lib]]
at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:125)
at java.lang.ClassLoader.loadClass(ClassLoader.java:379)
at java.lang.ClassLoader.loadClass(ClassLoader.java:312)
... 20 more
答案 0 :(得分:0)
根据您的描述,我发现一个线程存在相同的问题。
https://github.com/xamarin/GooglePlayServicesComponents/pull/130
也许您可以尝试在项目中添加 Xamarin.Google.Guava ,然后重试。