My custom Application class initializes some fields. There isn't any fancy logic to it, it is literally just assigning values.
This works for the majority of users, like in the millions. But if I go to the crash reports on the Play Store console I can see that the onCreate of my main Activity is trying to access one of those values and failing with kotlin.UninitializedPropertyAccessException. There aren't many reports, like ~100 users vs the millions that have used that version of the app.
My first thought was that these were users trying to crack my premium version, since one common thing they do is replace the Application class, but then I selected on the Play Store the filter that says installed from Google Play. The number of crashes dropped but it is still listed there.
So either my constructor is not getting called. Or the onCreate on my main Activity is getting called before, both of which sound impossible.
This is what my code looks like:
class MyApp: Application() {
init{
someVal = "someVal"
}
companion object{
lateinit var someVal:String
}
}
And then:
class MainActivity : AppCompatActivity(){
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
//this is where the exception kotlin.UninitializedPropertyAccessException happens.
val someVal = MyApp.someVal
}
}
Anyone have any thoughts on how this can be happening?