Skip to content

Installing Auth module causes SettingsSessionManager error in Native Kotlin #894

Closed Answered by unovil
unovil asked this question in Q&A
Discussion options

You must be logged in to vote

I found the solution! The problem was within the Settings() factory function of com.russhwolf.settings.Settings. This function gets called in createDefaultSettings() to be assigned by default to sessionManager when installing the Auth module.

However, Settings() needs to invoke the SharedPreferences API on Android, which isn't possible because this is a native Kotlin test, as stated by russhwolf here. To fix it, I have to mock the Context class first then initialize the Settings with the mocked context. Also, I have to manually set the Dispatcher since it would be used later on.

Here's the fixed code:

import android.content.Context
import com.russhwolf.settings.SettingsInitializer
import i…

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by unovil
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
1 participant