I don't know if onSaveInstanceState() is really possible to implement well without serializable continuations, but other Android REPLs work pretty well (particularly Ruboto IRB!), so you might find some ideas there.
---
@akkartik:
"autocomplete keeps trying to remove the space before commas"
Autocomplete ruins my day too. ^_^ You might be able to go to "Settings > Language & keyboard" to configure it. If it still happens after that, installing a new keyboard oughta help. At least it'll give you a fresh set of quirks to deal with. :-p