Reputation: 43
So I'm trying to create the Encrypted Shared prefs as shown in the dev android side : https://developer.android.com/reference/androidx/security/crypto/EncryptedSharedPreferences#inherited-methods And android studio doesn't seem to recognize it all all. My min skd is 23 is that reason form what I understand so far androidx doesnt require the newest android version?
Tried clean rebuild build etc. Tried migrating to androidx from Android studio menu ( getting the message of no usages found in project but I do have a few imports for androidx as I understood after checking it out)
import androidx.security.crypto.EncryptedSharedPreferences;
String masterKeyAlias = MasterKeys.getOrCreate(MasterKeys.AES256_GCM_SPEC);
SharedPreferences sharedPreferences = EncryptedSharedPreferences.create(
"secret_shared_prefs",
masterKeyAlias,
context,
EncryptedSharedPreferences.PrefKeyEncryptionScheme.AES256_SIV,
EncryptedSharedPreferences.PrefValueEncryptionScheme.AES256_GCM
);
//doesnt recognise MasterKeys nor EncryptedSharedPreferences classes
Upvotes: 4
Views: 6666
Reputation: 701
Add this to build.gradle file
api 'androidx.security:security-crypto:1.0.0'
Upvotes: 0
Reputation: 200130
As per the androidx.security
Declaring dependencies documentation, you need to add the dependency on the library:
dependencies {
def security_version = "1.0.0-alpha02"
implementation "androidx.security:security-crypto:$security_version"
}
Upvotes: 6