Christian Würthenr
12/11/2022, 6:51 AMby lazy
part:
val preferences by lazy { SharedBaseInjector.get().preferences } // Crash in this line
fun something() {
SharedBaseInjector.get().preferences // This is fine
val x = preferences.someValue
....
}
In debug mode everything is fine. If I wrap the preferences variable in an object it’s also fine in release mode:
private object Cache {
val preferences by lazy { SharedBaseInjector.get().preferences }
}
fun something() {
val x = Cache.preferences.someValue
....
}
Anyone having a clue what’s going on? The object fixes it for me…but I’d still like to understand what’s going onHee Fan
12/11/2022, 11:58 PMChristian Würthenr
12/12/2022, 8:21 AMby lazy
Christian Würthenr
12/12/2022, 8:21 AMHee Fan
12/14/2022, 2:30 AMlazy
. You can give a try without lazy
, directly use getter/setter function.