N00b needs help: Tutorial doesn't work

Hi,
I’m following this tutorial: https://www.mongodb.com/docs/realm/sdk/java/app-services/mongodb-remote-access/

But I keep getting the error: Unable to start activity CoomponentInfo{com.example.querytest3/com.example.querytest3.MainActivity}: java.lang.NullPointerException: Attempt to invoke virtual method ‘io.realm.mongodb.mongo.MongoClient io.realm.mongodb.User.getMongoClient(java.lang.String)’ on a null object reference

I get that it’s something with the anonymous user, from the code:
User user = app.currentUser();
MongoClient mongoClient =
user.getMongoClient(“mongodb-atlas”);

But how do I fix it? I know very very little about apps, I’m self-taught, and all I need is to learn how the tutorial works. Hopefully someone can help me with an extra line of code here or there? I can’t imagine it’s hard to fix, but I don’t have the experience to fix it, and I’ve literally spent hours searching the web for answers >.<

Thanks!

Okay, I’ve figured out that I’m missing the anonymous user declaration from here: https://www.mongodb.com/docs/realm/sdk/java/users/authenticate-users/#std-label-java-authenticate

But when I put that code above my current code, my next error is the line user.getMongoClient(“mongodb-atlas”): Cannot resolve method “getMongoClient” in ‘AtomicReference’.

Again I’m just literally following the tutorial, I’m not adding any extra code or editing it in any way. Why doesn’t it work?