Crash casting AndroidKeyStoreRSAPrivateKey to RSAPrivateKey
I'm following this tutorial: How to use the Android Keystore to store passwords and other sensitive information . It (loosely) ties up with the Google Sample app: BasicAndroidKeyStore . I can encrypt my data using the public key, and I can decrypt on devices running Lollipop. However I have a Nexus 6 running marshmallow and this crashes giving the error: java.lang.RuntimeException: Unable to create application com.android.test: java.lang.ClassCastException: android.security.keystore.AndroidKeyStoreRSAPrivateKey cannot be cast to java.security.interfaces.RSAPrivateKey Here is the code it