Android App与Firestore集成:无法到达Firestore后端

时间:2018-08-01 06:17:09

标签: java android firebase google-cloud-firestore

我无法从android应用上的firestore中获取数据。

仅出于测试目的,我试图按以下方式获取数据:-

FirebaseFirestore db = FirebaseFirestore.getInstance();
        this.collectionReference = db.collection("userData/tracking/users/someuser/books");
        db.document("userData/tracking").get().addOnSuccessListener(new OnSuccessListener<DocumentSnapshot>() {
            @Override
            public void onSuccess(DocumentSnapshot documentSnapshot) {
                if (documentPath.isEmpty())
                {
                    //some code....
                }
            }
        });

Note: userData/tracking/**users/someuser/books** part in bold doesn't exists. 
userData/tracking document exists.

But running the android app on debug mode, I get the following errors on console:-
W/common.FileUtils: Failed to set dir world executable: java.io.FileNotFoundException: /data/user_de/0/com.google.android.gms/files/gmscore_global_dirs.txt: open failed: EACCES (Permission denied)
W/System: ClassLoader referenced unknown path: /system/priv-app/PrebuiltGmsCore/lib/x86
W/common.FileUtils: Failed to set dir world executable: java.io.FileNotFoundException: /data/user_de/0/com.google.android.gms/files/gmscore_global_dirs.txt: open failed: EACCES (Permission denied)
W/System: ClassLoader referenced unknown path: /system/priv-app/PrebuiltGmsCore/lib/x86
W/common.FileUtils: Failed to set dir world executable: java.io.FileNotFoundException: /data/user_de/0/com.google.android.gms/files/gmscore_global_dirs.txt: open failed: EACCES (Permission denied)
W/System: ClassLoader referenced unknown path: /system/priv-app/PrebuiltGmsCore/lib/x86
W/common.FileUtils: Failed to set dir world executable: java.io.FileNotFoundException: /data/user_de/0/com.google.android.gms/files/gmscore_global_dirs.txt: open failed: EACCES (Permission denied)
W/System: ClassLoader referenced unknown path: /system/priv-app/PrebuiltGmsCore/lib/x86
W/linker: /data/user_de/0/com.google.android.gms/app_extracted_libs/x86/libconscrypt_gmscore_jni.so: unused DT entry: type 0xf arg 0x91
V/NativeCrypto: Registering com/google/android/gms/org/conscrypt/NativeCrypto's 279 native methods...
I/art: Background sticky concurrent mark sweep GC freed 20733(1775KB) AllocSpace objects, 34(680KB) LOS objects, 6% free, 34MB/37MB, paused 12.506ms total 132.706ms
I/ProviderInstaller: Installed default security provider GmsCore_OpenSSL
W/Firestore: (0.6.6-dev) [OnlineStateTracker]: Could not reach Firestore backend.

当我第一次使用Firestore时,请避免出现任何愚蠢的错误。当然,我缺少一些琐碎的东西。任何帮助或建议都会很棒!

1 个答案:

答案 0 :(得分:0)

确保正确定义了规则。如果您正在开发应用程序,则现在几乎不需要身份验证。因此,请在Rules标签中尝试以下操作:

service cloud.firestore {
  match /databases/{database}/documents {
    match /{document=**} {
      allow read, write;
    }
  }
}