I am trying to edit a user's set of shared preferences in a more secure way using EncryptedSharedPreferences
private fun provideSecureSharedPreference(context: Context): SharedPreferences {
val masterKey = MasterKey.Builder(context).setKeyScheme(MasterKey.KeyScheme.AES256_GCM).build()
return EncryptedSharedPreferences.create(
context, "secret_shared_prefs", masterKey, EncryptedSharedPreferences.PrefKeyEncryptionScheme.AES256_SIV,
EncryptedSharedPreferences.PrefValueEncryptionScheme.AES256_GCM
)
}
It runs fine when I use minifyEnabled false
Now I'm trying to Obfuscate the code by doing minifyEnabled true
To avoid other error, for now I have put just these lines in my proguard-rules.pro
file
-dontobfuscate
-optimizations !code/simplification/arithmetic,!field/*,!class/merging/*,!code/allocation/variable
but the probelem is when I set minifyEnable true
I am getting
java.io.FileNotFoundException: can't read keyset; the pref value __androidx_security_crypto_encrypted_prefs_key_keyset__ does not exist
I try to search old post from Stackoverflow and other channels but could not find the solution. Looking for a help thanks.