Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Unresolved reference: MasterKey

I am trying to follow examples given here: https://developer.android.com/topic/security/data

I have included the required libraries in my gradle:

implementation "androidx.security:security-crypto:1.0.0"

// For Identity Credential APIs
implementation "androidx.security:security-identity-credential:1.0.0-alpha02"

And yet when I try to use the code:

val mainKey = MasterKey.Builder(applicationContext)
    .setKeyScheme(MasterKey.KeyScheme.AES256_GCM)
    .build()

I get unresolved reference: MasterKey error. Does the library have that class at all?

Thanks in advance.

like image 505
TatiOverflow Avatar asked Aug 30 '26 17:08

TatiOverflow


1 Answers

Upgrade the library to latest version (1.1.0-alpha03 at the time of this writing)

implementation "androidx.security:security-crypto:1.1.0-alpha03"

From the release note, MasterKey is added on Version 1.1.0-alpha01.

Version 1.1.0-alpha01
...
New MasterKey class provides more options for keys, also deprecating MasterKeys to support new features and versions of Android that do not have KeyGenParamSpec.
like image 78
Jie Heng Avatar answered Sep 01 '26 05:09

Jie Heng