相关疑难解决方法(0)

androidx_security_crypto_encrypted_prefs_key_keyset不存在

我正在尝试使用更安全的方式编辑用户的共享首选项集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
    )
}
Run Code Online (Sandbox Code Playgroud)

当我使用时它运行良好minifyEnabled false 现在我正在尝试通过执行以下操作来混淆代码minifyEnabled true

为了避免其他错误,现在我只将这些行放入我的proguard-rules.pro文件中

-dontobfuscate
-optimizations !code/simplification/arithmetic,!field/*,!class/merging/*,!code/allocation/variable
Run Code Online (Sandbox Code Playgroud)

但问题是当我设置时minifyEnable true我得到

java.io.FileNotFoundException: can't read keyset; the pref value __androidx_security_crypto_encrypted_prefs_key_keyset__ does not exist
Run Code Online (Sandbox Code Playgroud)

我尝试从 Stackoverflow 和其他渠道搜索旧帖子,但找不到解决方案。寻求帮助谢谢。

obfuscation android sharedpreferences

11
推荐指数
1
解决办法
3245
查看次数

标签 统计

android ×1

obfuscation ×1

sharedpreferences ×1