I am following the documentation on Firebase website on setting up an Java Admin SDK. So I add the dependency to the build.gradle, and added the following code:
One other thing you can try is to explicitly wait until the setValue() task is complete using the Tasks API:
setValue()
Task task = usersRef.setValue(users); try { Tasks.await(task); } catch (ExecutionException | InterruptedException e) { // Handle error if necessary }