2
votes

I am getting this warning when instantiating the Firestore client.

fs = FirestoreClient.getFirestore();

The warning comes with the solution, to instancianciate the client in the following way:

FirestoreOptions options = 
FirestoreOptions.newBuilder().setTimestampsInSnapshotsEnabled(true).build();
Firestore firestore = options.getService();

Doing has suggested, after instantiate properly the default Firebase App, I get a null reference out of options.getService()

This happens only for Firebase admin sdk java version. It hides the warning works for NodeJs version.

According to the documentation for the java version I shouldn't need the new builder, at least that I can find it.

Current package version (from gradle build file):

compile 'com.google.firebase:firebase-admin:6.7.0'

Update:

I notice now that createTime property is returning a timestamp instead of a date, so it looks that the behavior is already changed regardless the way the client is initialized.

1

1 Answers

3
votes

For Admin SDK you should plumb the option through FirebaseOptions.

FirebaseOptions options =
          FirebaseOptions.builder()
              .setCredentials(credentials)
              .setFirestoreOptions(FirestoreOptions.newBuilder()
                  .setTimestampsInSnapshotsEnabled(true)                 
                  .build())
              .build();
FirebaseApp.initializeApp(options);
Firestore db = FirestoreClient.getFirestore();