Advanced & Automation Android 7.0+ (API 24+) Risk: MODIFIES_DEVICE

Force ART Ahead-Of-Time (AOT) Compilation

Forces the Android Runtime (ART) dex2oat compiler to pre-compile DEX bytecode into optimized native machine code.

Command Syntax

adb shell cmd package compile
Generic Syntax: cmd package compile -m <speed|speed-profile|quick|quicken|verify> [-f] [-r <REASON>] <package_name>|-a

Options & Parameters

Flag Description
-m speed Compile all methods into native machine code (maximum execution speed).
-m speed-profile Compile only hot methods identified in ART cloud profile.
-f Force re-compilation even if already compiled.
-a Compile all installed applications.

Real-World Usage Examples

Maximize performance: compile app with "speed" filter
Compiles DEX bytecode to native code for fastest execution.
adb shell cmd package compile -m speed -f com.spotify.music
Output:
Success
Compile all installed apps in background optimization mode
Optimizes entire system bytecode.
adb shell cmd package compile -r bg-dexopt -a
Output:
Success