How to set `omemoStoreBackEnd`?

This was asked by Nishan in our group chat, who has since left the chat. I’m reposting it in this forum, as that’s better suited for longer-term Q&A type of questions.

How to set omeoStoreBackEnd? I run into two mismatch errors while following the documentation provided on “https://download.igniterealtime.org/smack/dailybuilds/documentation/extensions/omemo.html”.

  1. when trying to put SignalFileBasedOmemoStore as wrapped store for SignalCachingOmemoStore, I get:

Assignment type mismatch: actual type is ‘SignalCachingOmemoStore’, but ‘Nothing!’ was expected

  1. Then when setting SignalCachingOmemoStore as omemoStoreBackEnd, I encounter the error:

Argument type mismatch: actual type is ‘SignalCachingOmemoStore’, but ‘OmemoStore<CapturedType()#9!, CapturedType()#8!, CapturedType()#7!, CapturedType()#6!, CapturedType()#5!, CapturedType()#4!, CapturedType()#3!, CapturedType()#2!, CapturedType(*)#1!>!’ was expected.

Done the following:

// Intialized
 OmemoInitializer().initialize()

//set up Omemo config & service
 SignalOmemoService.acknowledgeLicense()
 if (!SignalOmemoService.isServiceRegistered()) SignalOmemoService.setup()
 OmemoConfiguration.setAddOmemoHintBody(true)
 OmemoConfiguration.setRenewOldSignedPreKeys(true)
 OmemoConfiguration.setDeleteStaleDevices(true)

 // implementOmemoStore -- encountered error Assignmnt type mismatch here 
 val signalOmemoService = SignalOmemoService.getInstance()
 signalOmemoService.omemoStoreBackend = SignalCachingOmemoStore(SignalFileBasedOmemoStore(File("path/to/key")))

//initialize omemo Manager
omemoManager = OmemoManager.getInstanceFor(connection)
omemoManager.setTrustCallback(trustCallBack)
omemoManager.initializeAsync(omemoFinishedCallback)