androidsecuritycryptographykeystoreandroidx

Why androidx.security.crypto.MasterKeys is deprecated?


In the android developer's docs reference,here is the url androidx.security.crypto.MasterKeys

I found the MasterKeys class is deprecated and advise to use MasterKey.Builder to work with master keys.

But when i refer to the source code of "MasterKey.Builder" and found that it still call MasterKeys in the end.

I'm confused, why MasterKeys is deprecated but still worked.


Solution

  • An API that is marked deprecated means that it should not be used because it will be most likely removed in the future.

    Until the deprecated API has been removed (this can take months or even years) it can be used as before without problems. So not using the deprecated API means that you are prepared for the future.

    If you don't want to switch to a different API, you can still use the deprecated API until it has been removed, however when you upgrade to a version that has the API removed you have to adapt your code as compilation breaks. However if you now switch to the new API you are fine and don't have to worry when upgrading the library the next time.