我有一个方法
fun generateIdentity(deviceId:String, environment: String) {
val identity= Identity()
identity.deviceId = deviceId
identity.environment = environment
AppLog.i(TAG, "generateIdentity()")
if (!configDirectory.exists()) {
configDirectory.mkdirs()
}
val identityFile = File("$configDirectory/identity.json")
if (identityFile.exists()) {
identityFile.delete()
}
identityFile.createNewFile()
val jsonIdentity = GsonBuilder().setPrettyPrinting().create().toJson(identity)
try {
val buf = BufferedWriter(FileWriter(identityFile, true))
buf.append(jsonIdentity)
buf.newLine()
buf.close()
} catch (e: IOException) {
AppLog.e(TAG, e.printStackTrace().toString())
}
}
写一个序列化的对象
class Identity{
@Expose
@SerializedName("device-id")
var deviceId: String = ""
@Expose
@SerializedName("environment")
var environment: String =""
}
以 JSON 文件的形式存储到本地存储。
当在 Gson 构建过程中对标识对象调用 .toJson() 时,会在本机层发生崩溃,该层提供了一个非常长的日志列表,以
03-09 14:20:08.416 7468-7468/ A/art: art/runtime/entrypoints/quick/quick_trampoline_entrypoints.cc:801] Check failed: receiver != nullptr virtual
并以
03-09 14:20:08.799 7468-7468/? A/libc: Fatal signal 6 (SIGABRT), code -6 in tid 7468 ()
不生成墓碑。这是一段看似微不足道的代码,过去一直有效,不确定是什么变化导致了这种情况开始发生。我该如何调查是什么原因造成的?