# ProfileInstaller

# ProfileInstaller

Artifact:[androidx.profileinstaller:profileinstaller](https://developer.android.com/jetpack/androidx/releases/profileinstaller)  
[View Source](https://cs.android.com/search?q=file:androidx/profileinstaller/ProfileInstaller.java+class:androidx.profileinstaller.ProfileInstaller)  
Added in[1.0.0](https://developer.android.com/jetpack/androidx/releases/profileinstaller#1.0.0)

*** ** * ** ***

Kotlin\|[Java](https://developer.android.com/reference/androidx/profileinstaller/ProfileInstaller "View this page in Java")

<br />

```
class ProfileInstaller
```

<br />

*** ** * ** ***

Install ahead of time tracing profiles to configure ART to precompile bundled libraries. This will automatically be called by[ProfileInstallerInitializer](https://developer.android.com/reference/kotlin/androidx/profileinstaller/ProfileInstallerInitializer)and you should never call this unless you have disabled the initializer in your manifest. This reads profiles from the assets directory, where they must be embedded during the build process. This will have no effect if there is not a profile embedded in the current APK.

## Summary

|                                                                                                                                                          ### Nested types                                                                                                                                                           |
|-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| `interface `[ProfileInstaller.DiagnosticsCallback](https://developer.android.com/reference/kotlin/androidx/profileinstaller/ProfileInstaller.DiagnosticsCallback) An object which can be passed to the ProfileInstaller which will receive information during the installation process which can be used for logging and telemetry. |

|                                    ### Constants                                    |
|-------------------------------------------------------------------------------------|----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| `const `[Int](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html) | [DIAGNOSTIC_CURRENT_PROFILE_DOES_NOT_EXIST](https://developer.android.com/reference/kotlin/androidx/profileinstaller/ProfileInstaller#DIAGNOSTIC_CURRENT_PROFILE_DOES_NOT_EXIST())` = 2` Indicates that when tryInstallSync was run, no existing profile was found in the "cur" directory.                                       |
| `const `[Int](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html) | [DIAGNOSTIC_CURRENT_PROFILE_EXISTS](https://developer.android.com/reference/kotlin/androidx/profileinstaller/ProfileInstaller#DIAGNOSTIC_CURRENT_PROFILE_EXISTS())` = 1` Indicates that when tryInstallSync was run, an existing profile was found in the "cur" directory.                                                       |
| `const `[Int](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html) | [DIAGNOSTIC_PROFILE_IS_COMPRESSED](https://developer.android.com/reference/kotlin/androidx/profileinstaller/ProfileInstaller#DIAGNOSTIC_PROFILE_IS_COMPRESSED())` = 5` Indicates that the profile is compressed and a version of bundletool newer than 1.13.2 needs to be used to build the app.                                 |
| `const `[Int](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html) | [DIAGNOSTIC_REF_PROFILE_DOES_NOT_EXIST](https://developer.android.com/reference/kotlin/androidx/profileinstaller/ProfileInstaller#DIAGNOSTIC_REF_PROFILE_DOES_NOT_EXIST())` = 4` Indicates that when tryInstallSync was run, no existing profile was found in the "cur" directory.                                               |
| `const `[Int](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html) | [DIAGNOSTIC_REF_PROFILE_EXISTS](https://developer.android.com/reference/kotlin/androidx/profileinstaller/ProfileInstaller#DIAGNOSTIC_REF_PROFILE_EXISTS())` = 3` Indicates that when tryInstallSync was run, an existing profile was found in the "cur" directory.                                                               |
| `const `[Int](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html) | [RESULT_ALREADY_INSTALLED](https://developer.android.com/reference/kotlin/androidx/profileinstaller/ProfileInstaller#RESULT_ALREADY_INSTALLED())` = 2` Indicates that no installation occurred because it was determined that the baseline profile had already been installed previously.                                        |
| `const `[Int](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html) | [RESULT_BASELINE_PROFILE_NOT_FOUND](https://developer.android.com/reference/kotlin/androidx/profileinstaller/ProfileInstaller#RESULT_BASELINE_PROFILE_NOT_FOUND())` = 6` Indicates that no baseline profile was bundled with the APK, and as a result, no installation could take place.                                         |
| `const `[Int](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html) | [RESULT_BENCHMARK_OPERATION_FAILURE](https://developer.android.com/reference/kotlin/androidx/profileinstaller/ProfileInstaller#RESULT_BENCHMARK_OPERATION_FAILURE())` = 15` Indicates that the benchmark operation failed                                                                                                        |
| `const `[Int](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html) | [RESULT_BENCHMARK_OPERATION_SUCCESS](https://developer.android.com/reference/kotlin/androidx/profileinstaller/ProfileInstaller#RESULT_BENCHMARK_OPERATION_SUCCESS())` = 14` Indicates that the benchmark operation was successful                                                                                                |
| `const `[Int](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html) | [RESULT_BENCHMARK_OPERATION_UNKNOWN](https://developer.android.com/reference/kotlin/androidx/profileinstaller/ProfileInstaller#RESULT_BENCHMARK_OPERATION_UNKNOWN())` = 16` Indicates that the benchmark operation was unknown, likely meaning profileinstaller needs to update to support the operation                         |
| `const `[Int](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html) | [RESULT_DELETE_SKIP_FILE_SUCCESS](https://developer.android.com/reference/kotlin/androidx/profileinstaller/ProfileInstaller#RESULT_DELETE_SKIP_FILE_SUCCESS())` = 11` Indicates that a skip file was successfully deleted and profile installation will resume.                                                                  |
| `const `[Int](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html) | [RESULT_DESIRED_FORMAT_UNSUPPORTED](https://developer.android.com/reference/kotlin/androidx/profileinstaller/ProfileInstaller#RESULT_DESIRED_FORMAT_UNSUPPORTED())` = 5` Indicates that the format required by this SDK version is not supported by this version of the ProfileInstaller library.                                |
| `const `[Int](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html) | [RESULT_INSTALL_SKIP_FILE_SUCCESS](https://developer.android.com/reference/kotlin/androidx/profileinstaller/ProfileInstaller#RESULT_INSTALL_SKIP_FILE_SUCCESS())` = 10` Indicates that a skip file was successfully written and profile installation will be skipped.                                                            |
| `const `[Int](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html) | [RESULT_INSTALL_SUCCESS](https://developer.android.com/reference/kotlin/androidx/profileinstaller/ProfileInstaller#RESULT_INSTALL_SUCCESS())` = 1` Indicates that the profile got installed and written to disk successfully.                                                                                                    |
| `const `[Int](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html) | [RESULT_IO_EXCEPTION](https://developer.android.com/reference/kotlin/androidx/profileinstaller/ProfileInstaller#RESULT_IO_EXCEPTION())` = 7` Indicates that an IO Exception took place during install.                                                                                                                           |
| `const `[Int](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html) | [RESULT_META_FILE_REQUIRED_BUT_NOT_FOUND](https://developer.android.com/reference/kotlin/androidx/profileinstaller/ProfileInstaller#RESULT_META_FILE_REQUIRED_BUT_NOT_FOUND())` = 9` Indicates that the device requires a metadata file in order to install the profile successfully, but there was not one included in the APK. |
| `const `[Int](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html) | [RESULT_NOT_WRITABLE](https://developer.android.com/reference/kotlin/androidx/profileinstaller/ProfileInstaller#RESULT_NOT_WRITABLE())` = 4` Indicates that the installation was aborted because the app was found to not have adequate permissions to write the profile to disk.                                                |
| `const `[Int](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html) | [RESULT_PARSE_EXCEPTION](https://developer.android.com/reference/kotlin/androidx/profileinstaller/ProfileInstaller#RESULT_PARSE_EXCEPTION())` = 8` Indicates that a parsing exception occurred during install.                                                                                                                   |
| `const `[Int](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html) | [RESULT_SAVE_PROFILE_SIGNALLED](https://developer.android.com/reference/kotlin/androidx/profileinstaller/ProfileInstaller#RESULT_SAVE_PROFILE_SIGNALLED())` = 12` Indicates that this process was signalled to save it's profile information                                                                                     |
| `const `[Int](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html) | [RESULT_SAVE_PROFILE_SKIPPED](https://developer.android.com/reference/kotlin/androidx/profileinstaller/ProfileInstaller#RESULT_SAVE_PROFILE_SKIPPED())` = 13` Indicates that this process was not able to signal itself to save profile information                                                                              |
| `const `[Int](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html) | [RESULT_UNSUPPORTED_ART_VERSION](https://developer.android.com/reference/kotlin/androidx/profileinstaller/ProfileInstaller#RESULT_UNSUPPORTED_ART_VERSION())` = 3` Indicates that the current SDK level is such that installing a profile is not supported by ART.                                                               |

|                                    ### Public functions                                     |
|---------------------------------------------------------------------------------------------|-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| `java-static `[Unit](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html) | `@`[WorkerThread](https://developer.android.com/reference/kotlin/androidx/annotation/WorkerThread) [writeProfile](https://developer.android.com/reference/kotlin/androidx/profileinstaller/ProfileInstaller#writeProfile(android.content.Context))`(context: `[Context](https://developer.android.com/reference/android/content/Context.html)`)` Try to write the profile from assets into the ART aot profile directory.                                                                                                                                                                                                                                                                                                                                                                                   |
| `java-static `[Unit](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html) | `@`[WorkerThread](https://developer.android.com/reference/kotlin/androidx/annotation/WorkerThread) [writeProfile](https://developer.android.com/reference/kotlin/androidx/profileinstaller/ProfileInstaller#writeProfile(android.content.Context,java.util.concurrent.Executor,androidx.profileinstaller.ProfileInstaller.DiagnosticsCallback))`(` ` context: `[Context](https://developer.android.com/reference/android/content/Context.html)`,` ` executor: `[Executor](https://developer.android.com/reference/java/util/concurrent/Executor.html)`,` ` diagnostics: `[ProfileInstaller.DiagnosticsCallback](https://developer.android.com/reference/kotlin/androidx/profileinstaller/ProfileInstaller.DiagnosticsCallback) `)` Try to write the profile from assets into the ART aot profile directory. |

## Constants

### DIAGNOSTIC_CURRENT_PROFILE_DOES_NOT_EXIST

Added in[1.0.0](https://developer.android.com/jetpack/androidx/releases/profileinstaller#1.0.0)  

```
const val DIAGNOSTIC_CURRENT_PROFILE_DOES_NOT_EXIST = 2: Int
```

Indicates that when tryInstallSync was run, no existing profile was found in the "cur" directory.  

### DIAGNOSTIC_CURRENT_PROFILE_EXISTS

Added in[1.0.0](https://developer.android.com/jetpack/androidx/releases/profileinstaller#1.0.0)  

```
const val DIAGNOSTIC_CURRENT_PROFILE_EXISTS = 1: Int
```

Indicates that when tryInstallSync was run, an existing profile was found in the "cur" directory. The associated \[data\] passed in for this call will be the size, in bytes, of the profile that was found.  

### DIAGNOSTIC_PROFILE_IS_COMPRESSED

Added in[1.3.0](https://developer.android.com/jetpack/androidx/releases/profileinstaller#1.3.0)  

```
const val DIAGNOSTIC_PROFILE_IS_COMPRESSED = 5: Int
```

Indicates that the profile is compressed and a version of bundletool newer than 1.13.2 needs to be used to build the app.  

### DIAGNOSTIC_REF_PROFILE_DOES_NOT_EXIST

Added in[1.0.0](https://developer.android.com/jetpack/androidx/releases/profileinstaller#1.0.0)  

```
const val DIAGNOSTIC_REF_PROFILE_DOES_NOT_EXIST = 4: Int
```

Indicates that when tryInstallSync was run, no existing profile was found in the "cur" directory.  

### DIAGNOSTIC_REF_PROFILE_EXISTS

Added in[1.0.0](https://developer.android.com/jetpack/androidx/releases/profileinstaller#1.0.0)  

```
const val DIAGNOSTIC_REF_PROFILE_EXISTS = 3: Int
```

Indicates that when tryInstallSync was run, an existing profile was found in the "cur" directory. The associated \[data\] passed in for this call will be the size, in bytes, of the profile that was found.  

### RESULT_ALREADY_INSTALLED

Added in[1.0.0](https://developer.android.com/jetpack/androidx/releases/profileinstaller#1.0.0)  

```
const val RESULT_ALREADY_INSTALLED = 2: Int
```

Indicates that no installation occurred because it was determined that the baseline profile had already been installed previously.  

### RESULT_BASELINE_PROFILE_NOT_FOUND

Added in[1.0.0](https://developer.android.com/jetpack/androidx/releases/profileinstaller#1.0.0)  

```
const val RESULT_BASELINE_PROFILE_NOT_FOUND = 6: Int
```

Indicates that no baseline profile was bundled with the APK, and as a result, no installation could take place.  

### RESULT_BENCHMARK_OPERATION_FAILURE

Added in[1.3.0](https://developer.android.com/jetpack/androidx/releases/profileinstaller#1.3.0)  

```
const val RESULT_BENCHMARK_OPERATION_FAILURE = 15: Int
```

Indicates that the benchmark operation failed  

### RESULT_BENCHMARK_OPERATION_SUCCESS

Added in[1.3.0](https://developer.android.com/jetpack/androidx/releases/profileinstaller#1.3.0)  

```
const val RESULT_BENCHMARK_OPERATION_SUCCESS = 14: Int
```

Indicates that the benchmark operation was successful  

### RESULT_BENCHMARK_OPERATION_UNKNOWN

Added in[1.3.0](https://developer.android.com/jetpack/androidx/releases/profileinstaller#1.3.0)  

```
const val RESULT_BENCHMARK_OPERATION_UNKNOWN = 16: Int
```

Indicates that the benchmark operation was unknown, likely meaning profileinstaller needs to update to support the operation  

### RESULT_DELETE_SKIP_FILE_SUCCESS

Added in[1.2.0](https://developer.android.com/jetpack/androidx/releases/profileinstaller#1.2.0)  

```
const val RESULT_DELETE_SKIP_FILE_SUCCESS = 11: Int
```

Indicates that a skip file was successfully deleted and profile installation will resume.  

### RESULT_DESIRED_FORMAT_UNSUPPORTED

Added in[1.0.0](https://developer.android.com/jetpack/androidx/releases/profileinstaller#1.0.0)  

```
const val RESULT_DESIRED_FORMAT_UNSUPPORTED = 5: Int
```

Indicates that the format required by this SDK version is not supported by this version of the ProfileInstaller library.  

### RESULT_INSTALL_SKIP_FILE_SUCCESS

Added in[1.2.0](https://developer.android.com/jetpack/androidx/releases/profileinstaller#1.2.0)  

```
const val RESULT_INSTALL_SKIP_FILE_SUCCESS = 10: Int
```

Indicates that a skip file was successfully written and profile installation will be skipped.  

### RESULT_INSTALL_SUCCESS

Added in[1.0.0](https://developer.android.com/jetpack/androidx/releases/profileinstaller#1.0.0)  

```
const val RESULT_INSTALL_SUCCESS = 1: Int
```

Indicates that the profile got installed and written to disk successfully. Note that this should happen but is not the only condition that indicates "nothing went wrong". Several result codes are indicative of expected behavior.  

### RESULT_IO_EXCEPTION

Added in[1.0.0](https://developer.android.com/jetpack/androidx/releases/profileinstaller#1.0.0)  

```
const val RESULT_IO_EXCEPTION = 7: Int
```

Indicates that an IO Exception took place during install. The associated \[data\] with this result is the exception.  

### RESULT_META_FILE_REQUIRED_BUT_NOT_FOUND

Added in[1.1.0](https://developer.android.com/jetpack/androidx/releases/profileinstaller#1.1.0)  

```
const val RESULT_META_FILE_REQUIRED_BUT_NOT_FOUND = 9: Int
```

Indicates that the device requires a metadata file in order to install the profile successfully, but there was not one included in the APK. The correct metadata files are produced when using Android Gradle Plugin \`7.1.0-alpha05\` or newer.  

### RESULT_NOT_WRITABLE

Added in[1.0.0](https://developer.android.com/jetpack/androidx/releases/profileinstaller#1.0.0)  

```
const val RESULT_NOT_WRITABLE = 4: Int
```

Indicates that the installation was aborted because the app was found to not have adequate permissions to write the profile to disk.  

### RESULT_PARSE_EXCEPTION

Added in[1.0.0](https://developer.android.com/jetpack/androidx/releases/profileinstaller#1.0.0)  

```
const val RESULT_PARSE_EXCEPTION = 8: Int
```

Indicates that a parsing exception occurred during install. The associated \[data\] with this result is the exception.  

### RESULT_SAVE_PROFILE_SIGNALLED

Added in[1.3.0](https://developer.android.com/jetpack/androidx/releases/profileinstaller#1.3.0)  

```
const val RESULT_SAVE_PROFILE_SIGNALLED = 12: Int
```

Indicates that this process was signalled to save it's profile information  

### RESULT_SAVE_PROFILE_SKIPPED

Added in[1.3.0](https://developer.android.com/jetpack/androidx/releases/profileinstaller#1.3.0)  

```
const val RESULT_SAVE_PROFILE_SKIPPED = 13: Int
```

Indicates that this process was not able to signal itself to save profile information  

### RESULT_UNSUPPORTED_ART_VERSION

Added in[1.0.0](https://developer.android.com/jetpack/androidx/releases/profileinstaller#1.0.0)  

```
const val RESULT_UNSUPPORTED_ART_VERSION = 3: Int
```

Indicates that the current SDK level is such that installing a profile is not supported by ART.  

## Public functions

### writeProfile

Added in[1.0.0](https://developer.android.com/jetpack/androidx/releases/profileinstaller#1.0.0)  

```
@WorkerThread
java-static fun writeProfile(context: Context): Unit
```

Try to write the profile from assets into the ART aot profile directory. You do not need to call this method if[ProfileInstallerInitializer](https://developer.android.com/reference/kotlin/androidx/profileinstaller/ProfileInstallerInitializer)is enabled for your application. If you disable the initializer, you should**call this method within 5-10 seconds** of app launch, to ensure that art can use the generated profile. This should always be called after the first screen is shown to the user, to avoid delaying application startup to install AOT profiles. It is encouraged that you call this method during**every**app startup to ensure profiles are written correctly after app upgrades, or if the profile failed to write on the previous launch. Profiles will be correctly formatted based on the current API level of the device, and only installed if profileinstaller can determine that it is safe to do so. If the profile is not written, no action needs to be taken.  

|                                         Parameters                                         |
|--------------------------------------------------------------------------------------------|-----------------------------|
| `context: `[Context](https://developer.android.com/reference/android/content/Context.html) | context to read assets from |

### writeProfile

Added in[1.0.0](https://developer.android.com/jetpack/androidx/releases/profileinstaller#1.0.0)  

```
@WorkerThread
java-static fun writeProfile(
    context: Context,
    executor: Executor,
    diagnostics: ProfileInstaller.DiagnosticsCallback
): Unit
```

Try to write the profile from assets into the ART aot profile directory. You do not need to call this method if[ProfileInstallerInitializer](https://developer.android.com/reference/kotlin/androidx/profileinstaller/ProfileInstallerInitializer)is enabled for your application. If you disable the initializer, you should call this method within 5-10 seconds of app launch, to ensure that art can use the generated profile. This should always be called after the first screen is shown to the user, to avoid delaying application startup to install AOT profiles. It is encouraged that you call this method during**every**app startup to ensure profiles are written correctly after app upgrades, or if the profile failed to write on the previous launch. Profiles will be correctly formatted based on the current API level of the device, and only installed if profileinstaller can determine that it is safe to do so. If the profile is not written, no action needs to be taken.  

|                                                                              Parameters                                                                              |
|----------------------------------------------------------------------------------------------------------------------------------------------------------------------|----------------------------------------------------------------------------|
| `context: `[Context](https://developer.android.com/reference/android/content/Context.html)                                                                           | context to read assets from                                                |
| `executor: `[Executor](https://developer.android.com/reference/java/util/concurrent/Executor.html)                                                                   | the executor to run the diagnostic events through                          |
| `diagnostics: `[ProfileInstaller.DiagnosticsCallback](https://developer.android.com/reference/kotlin/androidx/profileinstaller/ProfileInstaller.DiagnosticsCallback) | an object which will receive diagnostic information about the installation |