Error initializing App to connect to Atlas within Android Studio

Hello, I have an issue with initializing my app to Atlas using Android Studio
I have been getting Initializer errors when running my program and I don’t know how to fix it.
I’ve tried upgrading my realm and kotlin versions in my top level build and that didn’t help. I tried upgrading my gradle plugins and that didn’t work.

Exception in thread “main” java.lang.ExceptionInInitializerError
at io.realm.kotlin.mongodb.AppConfiguration$Builder.(AppConfiguration.kt:162)
at io.realm.kotlin.mongodb.internal.AppImpl$Companion.create$io_realm_kotlin_library(AppImpl.kt:188)
at com.example.cuisinesync.AlgorithmAPIDB.Recommend.initializeRealm(WIPREC.kt:117)
at com.example.cuisinesync.AlgorithmAPIDB.WIPRECKt.main(WIPREC.kt:158)
at com.example.cuisinesync.AlgorithmAPIDB.WIPRECKt.main(WIPREC.kt)
Caused by: java.lang.NullPointerException
at io.realm.kotlin.internal.platform.SystemUtilsAndroidKt.(SystemUtilsAndroid.kt:19)
… 5 more
Process finished with exit code 1

This is the error I am getting.
The code in question:

fun initializeRealm() {
        val app = App.create(realmAppId)
        runBlocking {
            try {
                val user = app.login(Credentials.anonymous())
                val schemaSet = setOf(User::class as KClass<out RealmObject>)
                val syncConfig = SyncConfiguration.Builder(user, schema = schemaSet).build()
                realm =
            } catch (e: Exception) {
                println("Error initializing Realm: ${e.message}")

Here’s the code that calls the function:

fun main() {
    val recommend = Recommend(BuildConfig.APP_ID)

I checked and made sure realmAppId Is not null.
I am having problems with line 162 within the AppConfig.kt file:

What are you expecting that line to do? What does appFilesDirectory() resolve to?

I’m not particularly sure. The AppConfig file is read only and comes with the library that I am using for the project.
I found this documentation for the variable its connected to.

Sorry I posted a reply but didnt send it to you.

I’ve tried downgrading my gradle versions but so far none of them work.

Since the code is not working on that line, I would assume it’s because appFilesDirectory() is undefined. That could be caused by a missing library or some step overlooked when setting up your environment.

Going back through the setup guide may help.