Serialize icon indicating copy to clipboard operation
Serialize copied to clipboard

按照官方的都加了kotlinx.serialization,但还是一直报 java.io.NotSerializableException

Open rayzeng0221 opened this issue 7 months ago • 0 comments

下面是我的代码:

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"

    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

rayzeng0221 avatar Jul 03 '24 08:07 rayzeng0221