Cannot deserialize FormDef

Hello everyone!

I am having problems while deserializing previously saved FormDef objects.

Here is the async task that I am using for saving them:

class WriteCacheAsync : AsyncTask<Void, Void, Boolean>() {

    companion object {
        private val TAG = WriteCacheAsync::class.java.simpleName
    }

    override fun doInBackground(vararg params: Void?): Boolean {
        val formFile =
           File(Environment.getExternalStorageDirectory(), "sagacollect/collect.formdef")
        try {
            val dos = DataOutputStream(FileOutputStream(formFile))
            JRPresenter.getFormDef().writeExternal(dos)
            dos.close()
        } catch (exception: IOException) {
            Log.e(TAG, exception.toString())
        }
        return true
    }
}

And that is how I am trying to recover the FormDef after restarting the application.

class ReadCacheAsync(private val readCacheListener: ReadCacheListener) : AsyncTask<Void, Void, FormDef?>() {

    override fun doInBackground(vararg params: Void?): FormDef? {
        val testFile = File(
            Environment.getExternalStorageDirectory(),
            "sagacollect/collect.formdef"
        )
        if (testFile.exists()) {
            val deserializedFormDef = deserializeFormDef(testFile)
            if (deserializedFormDef != null) {
                return deserializedFormDef
            }
            testFile.delete()
        }
        return null
    }

    override fun onPostExecute(result: FormDef?) {
        readCacheListener.readCacheFinished(result)
    }

    private fun deserializeFormDef(serializedFormDef: File): FormDef? {
        var fd: FormDef?
        try {
            fd = FormDef()
            val fis = FileInputStream(serializedFormDef)
            val dis = DataInputStream(fis)
            fd.readExternal(dis, ExtUtil.defaultPrototypes())
            dis.close()
        } catch (e: Exception) {
            fd = null
        }
        return fd
    }
}

Currently, I am getting a DeserializationException in the line that does writeExternal(dos), with the message "No datatype registered to serialization code". So the result is always null and I cannot recover the state of an unfinished Form.

Any idea of what can I do in order to fix this? Otherwise, any idea of how to recover the state of a form after restarting the application?

Cheers,
Mauricio Güell