Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
codeZeng95 opened this issue Jul 3, 2024 · 0 comments

Comments

@codeZeng95
Copy link

下面是我的代码:

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant