gpt4 book ai didi

android - 在android中反序列化对象时出现StackOverFlowError

转载 作者:行者123 更新时间:2023-11-30 04:21:15 25 4
gpt4 key购买 nike

我一直在尝试反序列化由普通 JDK 在 Android 应用程序中创建的对象,每当我尝试这样做时,我都会收到 StackOverFlowError。

我可以在 davlik 虚拟机中使用我使用 JDK 序列化的对象吗?文件大小为 4 MB,它存储在 assets 文件夹中,生成错误的行如下

trie = (Trie<String, String>) new ObjectInputStream( ctx.getAssets().open(FILE_NAME)).readObject(); 


02-10 15:27:41.036: E/AndroidRuntime(2019): FATAL EXCEPTION: main
02-10 15:27:41.036: E/AndroidRuntime(2019): java.lang.StackOverflowError
02-10 15:27:41.036: E/AndroidRuntime(2019): at java.io.DataInputStream.readUnsignedShort(DataInputStream.java:414)
02-10 15:27:41.036: E/AndroidRuntime(2019): at java.io.DataInputStream.readUTF(DataInputStream.java:433)
02-10 15:27:41.036: E/AndroidRuntime(2019): at java.io.ObjectInputStream.readNewString(ObjectInputStream.java:2171)
02-10 15:27:41.036: E/AndroidRuntime(2019): at java.io.ObjectInputStream.readNonPrimitiveContent(ObjectInputStream.java:918)
02-10 15:27:41.036: E/AndroidRuntime(2019): at java.io.ObjectInputStream.readObject(ObjectInputStream.java:2262)
02-10 15:27:41.036: E/AndroidRuntime(2019): at java.io.ObjectInputStream.readObject(ObjectInputStream.java:2217)
02-10 15:27:41.036: E/AndroidRuntime(2019): at java.io.ObjectInputStream.readFieldValues(ObjectInputStream.java:1291)
02-10 15:27:41.036: E/AndroidRuntime(2019): at java.io.ObjectInputStream.defaultReadObject(ObjectInputStream.java:518)
02-10 15:27:41.036: E/AndroidRuntime(2019): at java.io.ObjectInputStream.readObjectForClass(ObjectInputStream.java:1535)
02-10 15:27:41.036: E/AndroidRuntime(2019): at java.io.ObjectInputStream.readHierarchy(ObjectInputStream.java:1443)
....

最佳答案

只是一个建议,你为什么不使用 KvmSerializable 它针对 android dalvik 进行了优化。

关于android - 在android中反序列化对象时出现StackOverFlowError,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9227161/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com