NullPointerException - Parameter specified as non-null is null (updatedKey)
See original GitHub issueHi, first of all, thanks for this awesome library, we are using in our KMM project, and its working great. We do have this issue that occurs on some devices, we have seen it on android 11 and 12, and not on android 10 and 9. Here is the stack trace
java.lang.NullPointerException: Parameter specified as non-null is null: method com.russhwolf.settings.AndroidSettings.addListener$lambda-1, parameter updatedKey
at com.russhwolf.settings.AndroidSettings.addListener$lambda-1
at com.russhwolf.settings.AndroidSettings.lambda$ejYPvc8UpZPLw0Pu9AuA51-Vbq8
at com.russhwolf.settings.-$$Lambda$AndroidSettings$ejYPvc8UpZPLw0Pu9AuA51-Vbq8.onSharedPreferenceChanged
at android.app.SharedPreferencesImpl$EditorImpl.notifyListeners(SharedPreferencesImpl.java:629)
at android.app.SharedPreferencesImpl$EditorImpl.lambda$notifyListeners$0$SharedPreferencesImpl$EditorImpl(SharedPreferencesImpl.java:643)
at android.app.SharedPreferencesImpl$EditorImpl$$ExternalSyntheticLambda0.run
at android.os.Handler.handleCallback(Handler.java:938)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loopOnce(Looper.java:226)
at android.os.Looper.loop(Looper.java:313)
at android.app.ActivityThread.main(ActivityThread.java:8633)
at java.lang.reflect.Method.invoke(Method.java)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:567)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1133)
What’s strange is that we do not attach any listeners when we are creating the Settings class in our Koin setup. So I am puzzled about how and why is Android SharedPreferences calling notifyListeners.
Issue Analytics
- State:
- Created a year ago
- Comments:5 (3 by maintainers)
Top Results From Across the Web
Kotlin NullPointerException: Parameter specified as non- ...
In this quick tutorial, we're going to see what happens when we store a null value into a non-null data type in Kotlin....
Read more >Parameter specified as non-null is null: method kotlin.jvm. ...
I'm getting this error. java.lang.IllegalArgumentException: Parameter specified as non-null is null ...
Read more >"NullPointerException: Parameter specified as non-null is ...
Running into this exception when using Anvil 2.1.0 with @AssistedInject on Kotlin version 1.4.30 with useIR = true. Repro repository. Steps to reproduce:....
Read more >Android Relations — How to avoid NullPointerException ...
Android Relations — How to avoid NullPointerException: Parameter specified as non-null is null. In this blog post I will discuss how to ...
Read more >method kotlin.jvm.internal.Intrinsics.checkParam - YouTube
Android : Parameter specified as non-null is null : method kotlin.jvm.internal.Intrinsics.checkParameterIsNotNull, parameter convertView ...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
This is fixed in version 0.9
Oh scratch that, it should be rare because
AndroidSettings.clear()
doesn’t callclear()
on theSharedPreferences
, it callsremove()
on every key instead. The only time you’ll see this issue is if you callpreferences.edit().clear().apply()
after setting listeners onAndroidSettings
. So a better workaround is to callclear()
on theSettings
instead of theSharedPreferences
.