1

I'm testing out the firestore setting up tutorial, but I'm hitting this wall that I just don't seems to find any solution to it. can anyone help?

I'm just following the basic setting up code, but am unable to add data to Firestore. I've already succeeded in testing realtime database and so now I'm testing the firestore.

this is the code in my main activity

FirebaseFirestore db = FirebaseFirestore.getInstance();

Map<String, Object> user = new HashMap<>();
        user.put("first", "Ada");
        user.put("last", "Lovelace");
        user.put("born", 1815);

db.collection("cities").document("LA")
            .set(user)
            .addOnSuccessListener(new OnSuccessListener<Void>() {
                @Override
                public void onSuccess(Void aVoid) {
                    Log.d(TAG, "DocumentSnapshot successfully written!");
                }
            })
            .addOnFailureListener(new OnFailureListener() {
                @Override
                public void onFailure(@NonNull Exception e) {
                    Log.w(TAG, "Error writing document", e);
                }
            });

and this is the error

04-23 01:32:05.450 3260-3320/com.lepuff.hendry.postest W/Firestore: (18.2.0) [Firestore]: Failed to update ssl context

04-23 01:32:05.710 3260-3320/com.lepuff.hendry.postest W/dalvikvm: Unable to resolve superclass of Lcom/google/firebase/firestore/remote/AndroidConnectivityMonitor$DefaultNetworkCallback; (399)

04-23 01:32:05.710 3260-3320/com.lepuff.hendry.postest W/dalvikvm: Link of class 'Lcom/google/firebase/firestore/remote/AndroidConnectivityMonitor$DefaultNetworkCallback;' failed

04-23 01:32:05.710 3260-3320/com.lepuff.hendry.postest E/dalvikvm: Could not find class 'com.google.firebase.firestore.remote.AndroidConnectivityMonitor$DefaultNetworkCallback', referenced from method com.google.firebase.firestore.remote.AndroidConnectivityMonitor.configureNetworkMonitoring

04-23 01:32:05.710 3260-3320/com.lepuff.hendry.postest W/dalvikvm: VFY: unable to resolve new-instance 6784 (Lcom/google/firebase/firestore/remote/AndroidConnectivityMonitor$DefaultNetworkCallback;) in Lcom/google/firebase/firestore/remote/AndroidConnectivityMonitor;

04-23 01:32:05.710 3260-3320/com.lepuff.hendry.postest W/dalvikvm: Unable to resolve superclass of Lcom/google/firebase/firestore/remote/AndroidConnectivityMonitor$DefaultNetworkCallback; (399)

04-23 01:32:05.710 3260-3320/com.lepuff.hendry.postest W/dalvikvm: Link of class 'Lcom/google/firebase/firestore/remote/AndroidConnectivityMonitor$DefaultNetworkCallback;' failed

04-23 01:32:05.710 3260-3320/com.lepuff.hendry.postest D/dalvikvm: DexOpt: unable to opt direct call 0xe049 at 0x0d in Lcom/google/firebase/firestore/remote/AndroidConnectivityMonitor;.configureNetworkMonitoring

this is the rule

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

already added the dependency, apply plugin, and classpath.

thanks and regards for any help.

Frank van Puffelen
  • 565,676
  • 79
  • 828
  • 807
Yoh Hendry
  • 417
  • 6
  • 15
  • there was some error i saw written like google play services util version was wrong. im wondering if that is the problem? i have no idea how to update it in the emulator though – Yoh Hendry Apr 22 '19 at 18:45

2 Answers2

3

Well, since waiting for 2 days and still no answer. i've figured out that when i test the code in my phone everything works out fine. finally was able to upload data to the firestore.

so im guessing the problem really could've been the google play services util version. but i've been trying for a whole day to only find a way to put play store in the emulator to no result. some says that changing to nougat version will make the play store to popup. but not for me.

thus, i give up and then tested the code with my phone.

hope this help someone else who might encounter this issue in the future. and hoping that android studio could help figure this out.

regards.

Yoh Hendry
  • 417
  • 6
  • 15
1

I think the problem you're having is that the emulator you're using doesn't have the Google playstore icon, therefore it doesn't come with the Google services,which is giving you the error.

The solution is to install an emulator with the Google playstore icon and I guess it should run just fine