英文:
'boolean java.lang.Class.isInterface()' on a null object reference
问题
I'm facing this crash on Android 13 at following code.
Caused by: java.lang.NullPointerException: Attempt to invoke virtual method 'boolean java.lang.Class.isInterface()' on a null object reference
Code:
val temp = if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.TIRAMISU)
bundle.getParcelable(ARG_TAG, Tab::class.java)
else
bundle.getParcelable(ARG_TAG)
DataClass (Tab) is as follow:
@Keep
@Parcelize
data class Tab(
val data: List
val icon: String? = null,
val provider: String? = null,
val subtype: String? = null,
val title: String,
val items: Int = 0
) : Parcelable
英文:
I'm facing this crash on Android 13 at following code.
Caused by: java.lang.NullPointerException: Attempt to invoke virtual method 'boolean java.lang.Class.isInterface()' on a null object reference
Code:
val temp = if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.TIRAMISU)
bundle.getParcelable(ARG_TAG, Tab::class.java)
else
bundle.getParcelable(ARG_TAG)
DataClass (Tab) is as follow:
@Keep
@Parcelize
data class Tab(
val data: List<String>? = null,
val icon: String? = null,
val provider: String? = null,
val subtype: String? = null,
val title: String,
val items: Int = 0
) : Parcelable
答案1
得分: 1
I've found solution, by using recommended approach for Android-13 BundleCompat
val temp = if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.TIRAMISU)
BundleCompat.getParcelable(bundle, ARG_TAG, Tab::class.java)
else
bundle.getParcelable(ARG_TAG)
英文:
I've found solution, by using recommended approach for Android-13 BundleCompat
val temp = if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.TIRAMISU)
BundleCompat.getParcelable(bundle, ARG_TAG, Tab::class.java)
else
bundle.getParcelable(ARG_TAG)
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论