You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
var userList :MutableList<UserInfo> by serialLazy(arrayListOf())
`import kotlinx.serialization.Serializable
@serializable
data class UserInfo (
var name: String? = null,
var age: Int? = null
)`
` val a = UserInfo()
a.age = 17
a.name = "zegyue"
val b = UserInfo()
b.age = 18
b.name = "zegyu1e"
val alist = mutableListOf(a,b)
AppCache.userList = alist`
报错: java.lang.Error: java.io.NotSerializableException: com.chihi.m98.bean.UserInfo at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1173) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:641) at java.lang.Thread.run(Thread.java:919) Caused by: java.io.NotSerializableException: com.chihi.m98.bean.UserInfo
The text was updated successfully, but these errors were encountered:
下面是我的代码:
plugins { id 'org.jetbrains.kotlin.multiplatform' version '2.0.0' id 'org.jetbrains.kotlin.plugin.serialization' version '2.0.0' }
id 'kotlinx-serialization'
implementation "org.jetbrains.kotlinx:kotlinx-serialization-json:1.7.1"
var userList :MutableList<UserInfo> by serialLazy(arrayListOf())
`import kotlinx.serialization.Serializable
@serializable
data class UserInfo (
var name: String? = null,
var age: Int? = null
)`
` val a = UserInfo()
a.age = 17
a.name = "zegyue"
报错:
java.lang.Error: java.io.NotSerializableException: com.chihi.m98.bean.UserInfo at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1173) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:641) at java.lang.Thread.run(Thread.java:919) Caused by: java.io.NotSerializableException: com.chihi.m98.bean.UserInfo
The text was updated successfully, but these errors were encountered: