Closed integral0909 closed 2 years ago
It'd be good to have the code, in order to understand what caused the crash
override fun onResume() {
super.onResume()
fillAccountSummary()
showHideSummaryBottom()
... ...
private fun showHideSummaryBottom(){
if (ATraderApp.prefs.pull(Constants.IS_SUMMARY_SHOWED, true)) {
binding.llSummary.visibility = View.VISIBLE
if (ATraderApp.prefs.pull(Constants.IS_Night_Mode, false)){
binding.ivSummaryIcon.setImageDrawable(ContextCompat.getDrawable(this, R.drawable.ic_summary_dark))
}else{
binding.ivSummaryIcon.setImageDrawable(ContextCompat.getDrawable(this, R.drawable.ic_summary_light))
}
binding.bottomNav.setBackgroundColor(getColor(R.color.color_background))
} else {
binding.llSummary.visibility = View.GONE
if (ATraderApp.prefs.pull(Constants.IS_Night_Mode, false)){
binding.bottomNav.setBackgroundColor(getColor(R.color.light_black))
}else{
binding.bottomNav.setBackgroundColor(getColor(R.color.light_bg_color))
}
binding.ivSummaryIcon.setImageDrawable(ContextCompat.getDrawable(this, R.drawable.ic_summary_up_trans))
}
....
and firebase crashylitics log
Caused by java.lang.NullPointerException com.cioccarellia.ksprefs.extensions.ReaderExtsKt.readOrThrow (ReaderExts.kt:34) com.cioccarellia.ksprefs.enclosure.KspEnclosure.readUnsafe$library (KspEnclosure.kt:69) com.cioccarellia.ksprefs.dispatcher.KspDispatcher.pull (KspDispatcher.kt:88) com.arktechltd.InfinityTradeZone.view.MainActivity.showHideSummaryBottom (MainActivity.kt:1590) com.arktechltd.InfinityTradeZone.view.MainActivity.onResume (MainActivity.kt:575)
The code seems to work fine. Can you provide a Minimal and Reproducible example?
My app produced java.lang.NullPointerException What is difference between java.lang.NullPointerException and KotlinNullPointerException?
in the following line
@CheckResult
internal fun Reader.readOrThrow(
key: String
): ByteArray = try {
getString(key, null)!!.bytes()
} catch (knpe: KotlinNullPointerException) {
throw NoSuchKeyException(key)
}
Without a mre I can't debug the issue and understand what happens. I suspect you may be making some inconsistent transactions on shared preferences which make the whole thing crash. To get this reopened, try to put together a working sample and provide more in-depth details (device, android version, Android studio version, target SDK, actual code, and whatever you think is going to help fix this issue).
Thanks for providing this library.
When I released new version of my android app which was using this library, App gets huge crashes because of the following function.
Caused by java.lang.NullPointerException com.cioccarellia.ksprefs.extensions.ReaderExtsKt.readOrThrow (ReaderExts.kt:34) com.cioccarellia.ksprefs.enclosure.KspEnclosure.readUnsafe$library (KspEnclosure.kt:69) com.cioccarellia.ksprefs.dispatcher.KspDispatcher.pull (KspDispatcher.kt:88)
Looking forward to hear from you. Thanks.