# KeyStoreException

Added in[API level 33](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)  
Summary:[Constants](https://developer.android.com/reference/android/security/KeyStoreException#constants)\|[Methods](https://developer.android.com/reference/android/security/KeyStoreException#pubmethods)\|[Inherited Methods](https://developer.android.com/reference/android/security/KeyStoreException#inhmethods)  

# KeyStoreException

*** ** * ** ***

[Kotlin](https://developer.android.com/reference/kotlin/android/security/KeyStoreException "View this page in Kotlin")\|Java

`
public


class
KeyStoreException
`  
`


``


``

extends `[Exception](https://developer.android.com/reference/java/lang/Exception)`


``


`

|---|---|---|------------------------------------|
| [java.lang.Object](https://developer.android.com/reference/java/lang/Object) ||||
| ↳ | [java.lang.Throwable](https://developer.android.com/reference/java/lang/Throwable) |||
|   | ↳ | [java.lang.Exception](https://developer.android.com/reference/java/lang/Exception) ||
|   |   | ↳ | android.security.KeyStoreException |

<br />

*** ** * ** ***

Exception containing information about the failure at the Keystore / KeyMint layer while generating or using a key. The public error codes indicate the cause of the error and the methods indicate whether it's a system/key issue and whether re-trying the operation (with the same key or a new key) is likely to succeed.

## Summary

|                                                                                                                                                                                       ### Constants                                                                                                                                                                                       ||
|-------|------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| `int` | [ERROR_ATTESTATION_CHALLENGE_TOO_LARGE](https://developer.android.com/reference/android/security/KeyStoreException#ERROR_ATTESTATION_CHALLENGE_TOO_LARGE) The attestation challenge specified is too large.                                                                                                                                                                        |
| `int` | [ERROR_ATTESTATION_KEYS_UNAVAILABLE](https://developer.android.com/reference/android/security/KeyStoreException#ERROR_ATTESTATION_KEYS_UNAVAILABLE) There are no keys available for attestation.                                                                                                                                                                                   |
| `int` | [ERROR_ID_ATTESTATION_FAILURE](https://developer.android.com/reference/android/security/KeyStoreException#ERROR_ID_ATTESTATION_FAILURE) The error related to inclusion of device identifiers in the attestation record.                                                                                                                                                            |
| `int` | [ERROR_INCORRECT_USAGE](https://developer.android.com/reference/android/security/KeyStoreException#ERROR_INCORRECT_USAGE) The feature the caller is trying to use is not compatible with the parameters used to generate the key.                                                                                                                                                  |
| `int` | [ERROR_INTERNAL_SYSTEM_ERROR](https://developer.android.com/reference/android/security/KeyStoreException#ERROR_INTERNAL_SYSTEM_ERROR) An internal system error - refer to[isTransientFailure()](https://developer.android.com/reference/android/security/KeyStoreException#isTransientFailure())to determine whether re-trying the operation is likely to yield different results. |
| `int` | [ERROR_KEYMINT_FAILURE](https://developer.android.com/reference/android/security/KeyStoreException#ERROR_KEYMINT_FAILURE) General error in the KeyMint layer.                                                                                                                                                                                                                      |
| `int` | [ERROR_KEYSTORE_FAILURE](https://developer.android.com/reference/android/security/KeyStoreException#ERROR_KEYSTORE_FAILURE) Failure in the Keystore layer.                                                                                                                                                                                                                         |
| `int` | [ERROR_KEYSTORE_UNINITIALIZED](https://developer.android.com/reference/android/security/KeyStoreException#ERROR_KEYSTORE_UNINITIALIZED) Indicating that`load()`has not been called on the Keystore instance, or an attempt has been made to generate an authorization bound key while the user has not set a lock screen knowledge factor (LSKF).                                  |
| `int` | [ERROR_KEY_CORRUPTED](https://developer.android.com/reference/android/security/KeyStoreException#ERROR_KEY_CORRUPTED) The key is corrupted and could not be recovered.                                                                                                                                                                                                             |
| `int` | [ERROR_KEY_DOES_NOT_EXIST](https://developer.android.com/reference/android/security/KeyStoreException#ERROR_KEY_DOES_NOT_EXIST) The key the operation refers to doesn't exist.                                                                                                                                                                                                     |
| `int` | [ERROR_KEY_NOT_TEMPORALLY_VALID](https://developer.android.com/reference/android/security/KeyStoreException#ERROR_KEY_NOT_TEMPORALLY_VALID) The key is not currently valid: Either at has expired or it will be valid for use in the future.                                                                                                                                       |
| `int` | [ERROR_KEY_OPERATION_EXPIRED](https://developer.android.com/reference/android/security/KeyStoreException#ERROR_KEY_OPERATION_EXPIRED) The crypto object the caller has been using held a reference to a KeyMint operation that has been evacuated (likely due to other concurrent operations taking place).                                                                        |
| `int` | [ERROR_OTHER](https://developer.android.com/reference/android/security/KeyStoreException#ERROR_OTHER) This error code is for mapping errors that the caller will not know about.                                                                                                                                                                                                   |
| `int` | [ERROR_PERMISSION_DENIED](https://developer.android.com/reference/android/security/KeyStoreException#ERROR_PERMISSION_DENIED) The caller has requested key parameters or operation which are only available to system or privileged apps.                                                                                                                                          |
| `int` | [ERROR_UNIMPLEMENTED](https://developer.android.com/reference/android/security/KeyStoreException#ERROR_UNIMPLEMENTED) The feature the caller is trying to use is not implemented by the underlying KeyMint implementation.                                                                                                                                                         |
| `int` | [ERROR_USER_AUTHENTICATION_REQUIRED](https://developer.android.com/reference/android/security/KeyStoreException#ERROR_USER_AUTHENTICATION_REQUIRED) Indicating the key could not be used because the user needs to authenticate first.                                                                                                                                             |
| `int` | [RETRY_AFTER_NEXT_REBOOT](https://developer.android.com/reference/android/security/KeyStoreException#RETRY_AFTER_NEXT_REBOOT) Re-try the operation that led to this error when the device has a software update downloaded and on the next reboot.                                                                                                                                 |
| `int` | [RETRY_NEVER](https://developer.android.com/reference/android/security/KeyStoreException#RETRY_NEVER) Never re-try the operation that led to this error, since it's a permanent error.                                                                                                                                                                                             |
| `int` | [RETRY_WHEN_CONNECTIVITY_AVAILABLE](https://developer.android.com/reference/android/security/KeyStoreException#RETRY_WHEN_CONNECTIVITY_AVAILABLE) Re-try the operation that led to this error when the device regains connectivity.                                                                                                                                                |
| `int` | [RETRY_WITH_EXPONENTIAL_BACKOFF](https://developer.android.com/reference/android/security/KeyStoreException#RETRY_WITH_EXPONENTIAL_BACKOFF) Re-try the operation that led to this error with an exponential back-off delay.                                                                                                                                                        |

|                                                                                                                                                             ### Public methods                                                                                                                                                              ||
|-----------------------------------------------------------------------|----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| ` int`                                                                | ` `[getNumericErrorCode](https://developer.android.com/reference/android/security/KeyStoreException#getNumericErrorCode())`() ` Returns one of the error codes exported by the class.                                                                                |
| ` int`                                                                | ` `[getRetryPolicy](https://developer.android.com/reference/android/security/KeyStoreException#getRetryPolicy())`() ` Returns the re-try policy for transient failures.                                                                                              |
| ` boolean`                                                            | ` `[isSystemError](https://developer.android.com/reference/android/security/KeyStoreException#isSystemError())`() ` Indicates whether the error related to the Keystore/KeyMint implementation and not a specific key.                                               |
| ` boolean`                                                            | ` `[isTransientFailure](https://developer.android.com/reference/android/security/KeyStoreException#isTransientFailure())`() ` Returns true if the failure is a transient failure - that is, performing the same operation again at a late time is likely to succeed. |
| ` boolean`                                                            | ` `[requiresUserAuthentication](https://developer.android.com/reference/android/security/KeyStoreException#requiresUserAuthentication())`() ` Indicates whether the failure is due to the device being locked.                                                       |
| ` `[String](https://developer.android.com/reference/java/lang/String) | ` `[toString](https://developer.android.com/reference/android/security/KeyStoreException#toString())`() ` Returns a short description of this throwable.                                                                                                             |

| ### Inherited methods |
|-----------------------|---|
| From class` `[java.lang.Throwable](https://developer.android.com/reference/java/lang/Throwable)` ` |-----------------------------------------------------------------------------------------------|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| | ` final void`                                                                                 | ` `[addSuppressed](https://developer.android.com/reference/java/lang/Throwable#addSuppressed(java.lang.Throwable))`(`[Throwable](https://developer.android.com/reference/java/lang/Throwable)` exception) ` Appends the specified exception to the exceptions that were suppressed in order to deliver this exception.                                                                                                                                                                                                            | | ` `[Throwable](https://developer.android.com/reference/java/lang/Throwable)                   | ` `[fillInStackTrace](https://developer.android.com/reference/java/lang/Throwable#fillInStackTrace())`() ` Fills in the execution stack trace.                                                                                                                                                                                                                                                                                                                                                                                    | | ` `[Throwable](https://developer.android.com/reference/java/lang/Throwable)                   | ` `[getCause](https://developer.android.com/reference/java/lang/Throwable#getCause())`() ` Returns the cause of this throwable or`null`if the cause is nonexistent or unknown.                                                                                                                                                                                                                                                                                                                                                    | | ` `[String](https://developer.android.com/reference/java/lang/String)                         | ` `[getLocalizedMessage](https://developer.android.com/reference/java/lang/Throwable#getLocalizedMessage())`() ` Creates a localized description of this throwable.                                                                                                                                                                                                                                                                                                                                                               | | ` `[String](https://developer.android.com/reference/java/lang/String)                         | ` `[getMessage](https://developer.android.com/reference/java/lang/Throwable#getMessage())`() ` Returns the detail message string of this throwable.                                                                                                                                                                                                                                                                                                                                                                               | | ` `[StackTraceElement[]](https://developer.android.com/reference/java/lang/StackTraceElement) | ` `[getStackTrace](https://developer.android.com/reference/java/lang/Throwable#getStackTrace())`() ` Provides programmatic access to the stack trace information printed by[printStackTrace()](https://developer.android.com/reference/java/lang/Throwable#printStackTrace()).                                                                                                                                                                                                                                                    | | ` final `[Throwable[]](https://developer.android.com/reference/java/lang/Throwable)           | ` `[getSuppressed](https://developer.android.com/reference/java/lang/Throwable#getSuppressed())`() ` Returns an array containing all of the exceptions that were suppressed, typically by the`try`-with-resources statement, in order to deliver this exception.                                                                                                                                                                                                                                                                  | | ` `[Throwable](https://developer.android.com/reference/java/lang/Throwable)                   | ` `[initCause](https://developer.android.com/reference/java/lang/Throwable#initCause(java.lang.Throwable))`(`[Throwable](https://developer.android.com/reference/java/lang/Throwable)` cause) ` Initializes the*cause*of this throwable to the specified value.                                                                                                                                                                                                                                                                   | | ` void`                                                                                       | ` `[printStackTrace](https://developer.android.com/reference/java/lang/Throwable#printStackTrace())`() ` Prints this throwable and its backtrace to the standard error stream.                                                                                                                                                                                                                                                                                                                                                    | | ` void`                                                                                       | ` `[printStackTrace](https://developer.android.com/reference/java/lang/Throwable#printStackTrace(java.io.PrintWriter))`(`[PrintWriter](https://developer.android.com/reference/java/io/PrintWriter)` s) ` Prints this throwable and its backtrace to the specified print writer.                                                                                                                                                                                                                                                  | | ` void`                                                                                       | ` `[printStackTrace](https://developer.android.com/reference/java/lang/Throwable#printStackTrace(java.io.PrintStream))`(`[PrintStream](https://developer.android.com/reference/java/io/PrintStream)` s) ` Prints this throwable and its backtrace to the specified print stream.                                                                                                                                                                                                                                                  | | ` void`                                                                                       | ` `[setStackTrace](https://developer.android.com/reference/java/lang/Throwable#setStackTrace(java.lang.StackTraceElement[]))`(`[StackTraceElement[]](https://developer.android.com/reference/java/lang/StackTraceElement)` stackTrace) ` Sets the stack trace elements that will be returned by[getStackTrace()](https://developer.android.com/reference/java/lang/Throwable#getStackTrace())and printed by[printStackTrace()](https://developer.android.com/reference/java/lang/Throwable#printStackTrace())and related methods. | | ` `[String](https://developer.android.com/reference/java/lang/String)                         | ` `[toString](https://developer.android.com/reference/java/lang/Throwable#toString())`() ` Returns a short description of this throwable.                                                                                                                                                                                                                                                                                                                                                                                         | ||
| From class` `[java.lang.Object](https://developer.android.com/reference/java/lang/Object)` ` |--------------------------------------------------------------------------------|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| | ` `[Object](https://developer.android.com/reference/java/lang/Object)          | ` `[clone](https://developer.android.com/reference/java/lang/Object#clone())`() ` Creates and returns a copy of this object.                                                                                                                                                      | | ` boolean`                                                                     | ` `[equals](https://developer.android.com/reference/java/lang/Object#equals(java.lang.Object))`(`[Object](https://developer.android.com/reference/java/lang/Object)` obj) ` Indicates whether some other object is "equal to" this one.                                           | | ` void`                                                                        | ` `[finalize](https://developer.android.com/reference/java/lang/Object#finalize())`() ` Called by the garbage collector on an object when garbage collection determines that there are no more references to the object.                                                          | | ` final `[Class](https://developer.android.com/reference/java/lang/Class)`<?>` | ` `[getClass](https://developer.android.com/reference/java/lang/Object#getClass())`() ` Returns the runtime class of this`Object`.                                                                                                                                                | | ` int`                                                                         | ` `[hashCode](https://developer.android.com/reference/java/lang/Object#hashCode())`() ` Returns a hash code value for the object.                                                                                                                                                 | | ` final void`                                                                  | ` `[notify](https://developer.android.com/reference/java/lang/Object#notify())`() ` Wakes up a single thread that is waiting on this object's monitor.                                                                                                                            | | ` final void`                                                                  | ` `[notifyAll](https://developer.android.com/reference/java/lang/Object#notifyAll())`() ` Wakes up all threads that are waiting on this object's monitor.                                                                                                                         | | ` `[String](https://developer.android.com/reference/java/lang/String)          | ` `[toString](https://developer.android.com/reference/java/lang/Object#toString())`() ` Returns a string representation of the object.                                                                                                                                            | | ` final void`                                                                  | ` `[wait](https://developer.android.com/reference/java/lang/Object#wait(long,%20int))`(long timeoutMillis, int nanos) ` Causes the current thread to wait until it is awakened, typically by being*notified* or*interrupted*, or until a certain amount of real time has elapsed. | | ` final void`                                                                  | ` `[wait](https://developer.android.com/reference/java/lang/Object#wait(long))`(long timeoutMillis) ` Causes the current thread to wait until it is awakened, typically by being*notified* or*interrupted*, or until a certain amount of real time has elapsed.                   | | ` final void`                                                                  | ` `[wait](https://developer.android.com/reference/java/lang/Object#wait())`() ` Causes the current thread to wait until it is awakened, typically by being*notified* or*interrupted*.                                                                                             | ||

## Constants

### ERROR_ATTESTATION_CHALLENGE_TOO_LARGE

Added in[API level 33](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)  

```
public static final int ERROR_ATTESTATION_CHALLENGE_TOO_LARGE
```

The attestation challenge specified is too large.

<br />

Constant Value: 9 (0x00000009)  

### ERROR_ATTESTATION_KEYS_UNAVAILABLE

Added in[API level 33](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)  

```
public static final int ERROR_ATTESTATION_KEYS_UNAVAILABLE
```

There are no keys available for attestation. This error is returned only on devices that rely solely on remotely-provisioned keys (see[Remote Key Provisioning](https://android-developers.googleblog.com/2022/03/upgrading-android-attestation-remote.html)).

On such a device, if the caller requests key generation and includes an attestation challenge (indicating key attestation is required), the error will be returned in one of the following cases:

- The pool of remotely-provisioned keys has been exhausted.
- The device is not registered with the key provisioning server.

<br />

This error is a transient one if the pool of remotely-provisioned keys has been exhausted. However, if the device is not registered with the server, or the key provisioning server refuses key issuance, this is a permanent error.

<br />

<br />

Constant Value: 16 (0x00000010)  

### ERROR_ID_ATTESTATION_FAILURE

Added in[API level 33](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)  

```
public static final int ERROR_ID_ATTESTATION_FAILURE
```

The error related to inclusion of device identifiers in the attestation record.

<br />

Constant Value: 8 (0x00000008)  

### ERROR_INCORRECT_USAGE

Added in[API level 33](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)  

```
public static final int ERROR_INCORRECT_USAGE
```

The feature the caller is trying to use is not compatible with the parameters used to generate the key. For example, trying to use a key generated for a different signature algorithm, or a digest not specified during key creation. Another case is the attempt to generate a symmetric AES key and requesting key attestation.

<br />

Constant Value: 13 (0x0000000d)  

### ERROR_INTERNAL_SYSTEM_ERROR

Added in[API level 33](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)  

```
public static final int ERROR_INTERNAL_SYSTEM_ERROR
```

An internal system error - refer to[isTransientFailure()](https://developer.android.com/reference/android/security/KeyStoreException#isTransientFailure())to determine whether re-trying the operation is likely to yield different results.

<br />

Constant Value: 4 (0x00000004)  

### ERROR_KEYMINT_FAILURE

Added in[API level 33](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)  

```
public static final int ERROR_KEYMINT_FAILURE
```

General error in the KeyMint layer.

<br />

Constant Value: 10 (0x0000000a)  

### ERROR_KEYSTORE_FAILURE

Added in[API level 33](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)  

```
public static final int ERROR_KEYSTORE_FAILURE
```

Failure in the Keystore layer.

<br />

Constant Value: 11 (0x0000000b)  

### ERROR_KEYSTORE_UNINITIALIZED

Added in[API level 33](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)  

```
public static final int ERROR_KEYSTORE_UNINITIALIZED
```

Indicating that`load()`has not been called on the Keystore instance, or an attempt has been made to generate an authorization bound key while the user has not set a lock screen knowledge factor (LSKF). Instruct the user to set an LSKF and retry.

<br />

Constant Value: 3 (0x00000003)  

### ERROR_KEY_CORRUPTED

Added in[API level 33](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)  

```
public static final int ERROR_KEY_CORRUPTED
```

The key is corrupted and could not be recovered.

<br />

Constant Value: 7 (0x00000007)  

### ERROR_KEY_DOES_NOT_EXIST

Added in[API level 33](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)  

```
public static final int ERROR_KEY_DOES_NOT_EXIST
```

The key the operation refers to doesn't exist.

<br />

Constant Value: 6 (0x00000006)  

### ERROR_KEY_NOT_TEMPORALLY_VALID

Added in[API level 33](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)  

```
public static final int ERROR_KEY_NOT_TEMPORALLY_VALID
```

The key is not currently valid: Either at has expired or it will be valid for use in the future.

<br />

Constant Value: 14 (0x0000000e)  

### ERROR_KEY_OPERATION_EXPIRED

Added in[API level 33](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)  

```
public static final int ERROR_KEY_OPERATION_EXPIRED
```

The crypto object the caller has been using held a reference to a KeyMint operation that has been evacuated (likely due to other concurrent operations taking place). The caller should re-create the crypto object and try again.

<br />

Constant Value: 15 (0x0000000f)  

### ERROR_OTHER

Added in[API level 33](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)  

```
public static final int ERROR_OTHER
```

This error code is for mapping errors that the caller will not know about. If the caller is targeting an API level earlier than the one the error was introduced in, then the error will be mapped to this one. In API level 33 no errors map to this error.

<br />

Constant Value: 1 (0x00000001)  

### ERROR_PERMISSION_DENIED

Added in[API level 33](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)  

```
public static final int ERROR_PERMISSION_DENIED
```

The caller has requested key parameters or operation which are only available to system or privileged apps.

<br />

Constant Value: 5 (0x00000005)  

### ERROR_UNIMPLEMENTED

Added in[API level 33](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)  

```
public static final int ERROR_UNIMPLEMENTED
```

The feature the caller is trying to use is not implemented by the underlying KeyMint implementation. This could happen when an unsupported algorithm is requested, or when trying to import a key in a format other than raw or PKCS#8.

<br />

Constant Value: 12 (0x0000000c)  

### ERROR_USER_AUTHENTICATION_REQUIRED

Added in[API level 33](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)  

```
public static final int ERROR_USER_AUTHENTICATION_REQUIRED
```

Indicating the key could not be used because the user needs to authenticate first. See[KeyGenParameterSpec.Builder.setUserAuthenticationRequired(boolean)](https://developer.android.com/reference/android/security/keystore/KeyGenParameterSpec.Builder#setUserAuthenticationRequired(boolean)).

<br />

Constant Value: 2 (0x00000002)  

### RETRY_AFTER_NEXT_REBOOT

Added in[API level 34](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)  

```
public static final int RETRY_AFTER_NEXT_REBOOT
```

Re-try the operation that led to this error when the device has a software update downloaded and on the next reboot. The Remote provisioning server recognizes the device, but refuses issuance of attestation keys because it contains a software version that could potentially be vulnerable and needs an update. Re-trying after the device has upgraded and rebooted may alleviate the problem.

This value is returned when[isTransientFailure()](https://developer.android.com/reference/android/security/KeyStoreException#isTransientFailure())is`true`.

<br />

Constant Value: 4 (0x00000004)  

### RETRY_NEVER

Added in[API level 33](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)  

```
public static final int RETRY_NEVER
```

Never re-try the operation that led to this error, since it's a permanent error. This value is always returned when[isTransientFailure()](https://developer.android.com/reference/android/security/KeyStoreException#isTransientFailure())is`false`.

<br />

Constant Value: 1 (0x00000001)  

### RETRY_WHEN_CONNECTIVITY_AVAILABLE

Added in[API level 33](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)  

```
public static final int RETRY_WHEN_CONNECTIVITY_AVAILABLE
```

Re-try the operation that led to this error when the device regains connectivity. Remote provisioning of keys requires reaching the remote server, and the device is currently unable to due that due to lack of network connectivity. This value is returned when[isTransientFailure()](https://developer.android.com/reference/android/security/KeyStoreException#isTransientFailure())is`true`.

<br />

Constant Value: 3 (0x00000003)  

### RETRY_WITH_EXPONENTIAL_BACKOFF

Added in[API level 33](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)  

```
public static final int RETRY_WITH_EXPONENTIAL_BACKOFF
```

Re-try the operation that led to this error with an exponential back-off delay. The first delay should be between 5 to 30 seconds, and each subsequent re-try should double the delay time. This value is returned when[isTransientFailure()](https://developer.android.com/reference/android/security/KeyStoreException#isTransientFailure())is`true`.

<br />

Constant Value: 2 (0x00000002)

## Public methods

### getNumericErrorCode

Added in[API level 33](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)  

```
public int getNumericErrorCode ()
```

Returns one of the error codes exported by the class.

<br />

|                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                Returns                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                 ||
|-------|---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| `int` | a public error code Value is either`0`or a combination of[ERROR_OTHER](https://developer.android.com/reference/android/security/KeyStoreException#ERROR_OTHER),[ERROR_USER_AUTHENTICATION_REQUIRED](https://developer.android.com/reference/android/security/KeyStoreException#ERROR_USER_AUTHENTICATION_REQUIRED),[ERROR_KEYSTORE_UNINITIALIZED](https://developer.android.com/reference/android/security/KeyStoreException#ERROR_KEYSTORE_UNINITIALIZED),[ERROR_INTERNAL_SYSTEM_ERROR](https://developer.android.com/reference/android/security/KeyStoreException#ERROR_INTERNAL_SYSTEM_ERROR),[ERROR_PERMISSION_DENIED](https://developer.android.com/reference/android/security/KeyStoreException#ERROR_PERMISSION_DENIED),[ERROR_KEY_DOES_NOT_EXIST](https://developer.android.com/reference/android/security/KeyStoreException#ERROR_KEY_DOES_NOT_EXIST),[ERROR_KEY_CORRUPTED](https://developer.android.com/reference/android/security/KeyStoreException#ERROR_KEY_CORRUPTED),[ERROR_ID_ATTESTATION_FAILURE](https://developer.android.com/reference/android/security/KeyStoreException#ERROR_ID_ATTESTATION_FAILURE),[ERROR_ATTESTATION_CHALLENGE_TOO_LARGE](https://developer.android.com/reference/android/security/KeyStoreException#ERROR_ATTESTATION_CHALLENGE_TOO_LARGE),[ERROR_KEYMINT_FAILURE](https://developer.android.com/reference/android/security/KeyStoreException#ERROR_KEYMINT_FAILURE),[ERROR_KEYSTORE_FAILURE](https://developer.android.com/reference/android/security/KeyStoreException#ERROR_KEYSTORE_FAILURE),[ERROR_UNIMPLEMENTED](https://developer.android.com/reference/android/security/KeyStoreException#ERROR_UNIMPLEMENTED),[ERROR_INCORRECT_USAGE](https://developer.android.com/reference/android/security/KeyStoreException#ERROR_INCORRECT_USAGE),[ERROR_KEY_NOT_TEMPORALLY_VALID](https://developer.android.com/reference/android/security/KeyStoreException#ERROR_KEY_NOT_TEMPORALLY_VALID),[ERROR_KEY_OPERATION_EXPIRED](https://developer.android.com/reference/android/security/KeyStoreException#ERROR_KEY_OPERATION_EXPIRED),[ERROR_ATTESTATION_KEYS_UNAVAILABLE](https://developer.android.com/reference/android/security/KeyStoreException#ERROR_ATTESTATION_KEYS_UNAVAILABLE), and android.security.KeyStoreException.ERROR_DEVICE_REQUIRES_UPGRADE_FOR_ATTESTATION <br /> |

### getRetryPolicy

Added in[API level 33](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)  

```
public int getRetryPolicy ()
```

Returns the re-try policy for transient failures. Valid only if[isTransientFailure()](https://developer.android.com/reference/android/security/KeyStoreException#isTransientFailure())returns`True`.

<br />

|                                                                                                                                                                                                                                                                                         Returns                                                                                                                                                                                                                                                                                          ||
|-------|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| `int` | Value is either`0`or a combination of[RETRY_NEVER](https://developer.android.com/reference/android/security/KeyStoreException#RETRY_NEVER),[RETRY_WITH_EXPONENTIAL_BACKOFF](https://developer.android.com/reference/android/security/KeyStoreException#RETRY_WITH_EXPONENTIAL_BACKOFF),[RETRY_WHEN_CONNECTIVITY_AVAILABLE](https://developer.android.com/reference/android/security/KeyStoreException#RETRY_WHEN_CONNECTIVITY_AVAILABLE), and[RETRY_AFTER_NEXT_REBOOT](https://developer.android.com/reference/android/security/KeyStoreException#RETRY_AFTER_NEXT_REBOOT) <br /> |

### isSystemError

Added in[API level 33](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)  

```
public boolean isSystemError ()
```

Indicates whether the error related to the Keystore/KeyMint implementation and not a specific key.

<br />

|                                                                                              Returns                                                                                               ||
|-----------|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| `boolean` | true if the error is related to the system, not the key in use. System errors indicate a feature isn't working, whereas key-related errors are likely to succeed with a new key. <br /> |

### isTransientFailure

Added in[API level 33](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)  

```
public boolean isTransientFailure ()
```

Returns true if the failure is a transient failure - that is, performing the same operation again at a late time is likely to succeed. If[isSystemError()](https://developer.android.com/reference/android/security/KeyStoreException#isSystemError())returns true, the transient nature of the failure relates to the device, otherwise relates to the key (so a permanent failure with an existing key likely requires creating another key to repeat the operation with).

<br />

|      Returns      ||
|-----------|--------|
| `boolean` | <br /> |

### requiresUserAuthentication

Added in[API level 33](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)  

```
public boolean requiresUserAuthentication ()
```

Indicates whether the failure is due to the device being locked.

<br />

|                                                         Returns                                                         ||
|-----------|--------------------------------------------------------------------------------------------------------------|
| `boolean` | true if the key operation failed because the user has to authenticate (e.g. by unlocking the device). <br /> |

### toString

Added in[API level 33](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)  

```
public String toString ()
```

Returns a short description of this throwable. The result is the concatenation of:

- the[name](https://developer.android.com/reference/java/lang/Class#getName())of the class of this object
- ": " (a colon and a space)
- the result of invoking this object's[getLocalizedMessage()](https://developer.android.com/reference/java/lang/Throwable#getLocalizedMessage())method

If`getLocalizedMessage`returns`null`, then just the class name is returned.

<br />

<br />

|                                                        Returns                                                        ||
|--------------------------------------------------------------------|---------------------------------------------------|
| [String](https://developer.android.com/reference/java/lang/String) | a string representation of this throwable. <br /> |