Navigating Android Package Management
Elevate your Android development and management skills with this extensive guide on package management. Covering everything from app installation, permissions handling, to user and app link management, this resource is designed for developers looking to streamline their workflow. Whether you're aiming to optimize app performance, manage permissions efficiently, or handle complex app links scenarios, this guide provides actionable insights and detailed ADB commands to enhance your Android experience.
Print this help text.
pm help
Print the path to the .apk of the given PACKAGE.
pm path --user 0 com.android.settings
Print various system state associated with the given PACKAGE.
pm dump com.android.settings
Prints true and returns exit status 0 when the system has a FEATURE_NAME, otherwise prints false and returns exit status 1.
pm has-feature FEATURE_NAME [version]
Prints all features of the system.
pm list features
Prints all test packages; optionally only those targeting TARGET-PACKAGE.
pm list instrumentation [-f] [TARGET-PACKAGE]
Prints all system libraries.
pm list libraries
List Packages
Prints all packages and their associated files.
pm list packages -f
Prints all known packages, excluding APEXes.
pm list packages -a
Filters and shows only disabled packages.
pm list packages -d
Filters and shows only enabled packages.
pm list packages -e
Filters and shows only system packages.
pm list packages -s
Filters and shows only third-party packages.
pm list packages -3
Shows the installer for the packages.
pm list packages -i
Ignored (used for compatibility with older releases).
pm list packages -l
Also shows the package UID.
pm list packages -U
Includes uninstalled packages.
pm list packages -u
Also shows the version code.
pm list packages --show-versioncode
Only shows APEX packages.
pm list packages --apex-only
Filters and shows packages with the given UID.
pm list packages --uid UID
Only lists packages belonging to the given user.
pm list packages --user USER_ID
Prints all known permission groups.
pm list permission-groups
List Permissions
List all permissions.
pm list permission -g
List permissions and their groups.
pm list permission -f
List only system permissions.
pm list permission -s
List only disabled permissions.
pm list permission -d
List only user permissions.
pm list permission -u
List all staged sessions.
pm list staged-sessions
List only ready staged sessions.
pm list staged-sessions --only-ready
List only session IDs of staged sessions.
pm list staged-sessions --only-sessionid
List only parent staged sessions.
pm list staged-sessions --only-parent
List Users
pm list users
Prints the activity that resolves to the given INTENT.
pm resolve-activity --brief --components --query-flags FLAGS --user 0 INTENT
Prints all activities that can handle the given INTENT.
pm query-activities --brief --components --query-flags FLAGS --user 0 INTENT
Prints all services that can handle the given INTENT.
pm query-services --brief --components --query-flags FLAGS --user 0 INTENT
Prints all broadcast receivers that can handle the given INTENT.
pm query-receivers --brief --components --query-flags FLAGS --user 0 INTENT
Install package with default options for user 0
pm install -r -i PACKAGE --user 0
Install package with default options for all users
pm install -r -i PACKAGE --user all
Install package with default options for the current user
pm install -r -i PACKAGE --user current
Install package with the option to retain data and cache for user 0
pm install -t -i PACKAGE --user 0
Install package with the option to retain data and cache for all users
pm install -t -i PACKAGE --user all
Install package with the option to retain data and cache for the current user
pm install -t -i PACKAGE --user current
Install package with the option to retain only the cache for user 0
pm install -t -i PACKAGE --user 0
Install package with the option to retain only the cache for all users:
pm install -t -i PACKAGE --user all
Install package with the option to retain only the cache for the current user
pm install -t -i PACKAGE --user current
Install package with the option to grant all runtime permissions and retain data and cache for user 0
pm install -g -i PACKAGE --user 0
Install package with the option to grant all runtime permissions and retain data and cache for all users
pm install -g -i PACKAGE --user all
Install package with the option to grant all runtime permissions and retain data and cache for the current user
pm install -g -i PACKAGE --user current
Install
pm install -p INHERIT_PACKAGE
Install Location
| Location Code | Description |
|---|---|
| 0 | Auto |
| 1 | Internal Only |
| 2 | Prefer External |
pm set-install-location 0/1/2
Install with Reason
| Reason Code | Description |
|---|---|
| 0 | Unknown reason |
| 1 | Replacement of an existing package |
| 2 | New installation |
| 3 | Restoration of a package from backup |
| 4 | Upgrade of an existing package |
pm install-create -r -i PACKAGE --install-reason 0/1/2/3/4
Originating URI
pm install-write -S BYTES --originating-uri URI
Referrer URI
pm install-write -S BYTES --referrer URI
ABI (CPU Architecture)
pm install -r -i PACKAGE --abi ABI_NAME
Force SDK
pm install -t -i PACKAGE --force-sdk
Preload
pm install --preload
Instant
pm install --instant
Full Install
pm install -r -i PACKAGE --full
Don't Kill
pm install -r -i PACKAGE --dont-kill
Enable Rollback
pm install --enable-rollback
Force UUID
pm install --force-uuid internal|UUID
Package
pm install -r -i PACKAGE
File Size
pm install -S BYTES
Install Apex Package
pm install -g -i PACKAGE
Staged Ready Timeout
pm install --staged-ready-timeout TIMEOUT
Install Path
pm install -r -i PACKAGE --user 0 PATH [SPLIT...]|-
Install with Reason
| Reason Code | Description |
|---|---|
| 0 | Unknown |
| 1 | Admin Policy |
| 2 | Device Restore |
| 3 | Device Setup |
| 4 | User Request |
pm install-create -r REASON
pm install-write --force-uuid internal|UUID
pm install-write --apex
pm install --staged-ready-timeout TIMEOUT
Install Create with User ID
To specify the user ID for the installation, you can use the following commands:
pm install-create --user USER_ID
Replace USER_ID with the desired user ID. For example, to specify the system user (ID 0), you can use:
pm install-create --user 0
Install Create for All Users
To install the package for all users on a multi-user device, you can use the following command:
pm install-create --user all
Install Create for Current User
To install the package for the current user, you can use the following command:
pm install-create --user current
install-existing
Install Existing Package with User ID
pm install-existing --user
Install Existing Package as Instant App
pm install-existing --instant
Install Existing Package as Full App
pm install-existing --full
Install Existing Package and Wait
pm install-existing --wait
Install Existing Package without Whitelisting Restricted Permissions
pm install-existing --restrict-permissions
Install Write
pm install-write [-S BYTES] SESSION_ID SPLIT_NAME [PATH|-]
Install Remove
pm install-remove SESSION_ID SPLIT...
Install Add Session
pm install-add-session MULTI_PACKAGE_SESSION_ID CHILD_SESSION_IDs
Install Commit
pm install-commit SESSION_ID
Install Abandon
pm install-abandon SESSION_ID
Install Location
0 [auto]: Let system decide the best location 1 [internal]: Install on internal device storage 2 [external]: Install on external media
Set Install Location to Auto
pm set-install-location 0
Set Install Location to Internal Only
pm set-install-location 1
Set Install Location to Prefer External
pm set-install-location 2
Get Install Location
pm get-install-location
Move Package
pm move-package PACKAGE [internal|UUID]
Move Primary Storage
pm move-primary-storage [internal|UUID]
Uninstall Package
pm uninstall [-k] --user 0 [--versionCode VERSION_CODE] PACKAGE [SPLIT...]
Clear Package Data
pm clear --user 0 [--cache-only] PACKAGE
Enable Package or Component
pm enable --user 0 PACKAGE_OR_COMPONENT
Disable Package or Component
pm disable --user 0 PACKAGE_OR_COMPONENT
Disable User for Package or Component
pm disable-user --user 0 PACKAGE_OR_COMPONENT
Disable Until Used for Package or Component
pm disable-until-used --user 0 PACKAGE_OR_COMPONENT
Set Default State for Package or Component
pm default-state --user 0 PACKAGE_OR_COMPONENT
Hide Package or Component
pm hide --user 0 PACKAGE_OR_COMPONENT
Unhide Package or Component
pm unhide --user 0 PACKAGE_OR_COMPONENT
Suspend Packages
pm suspend --user 0 PACKAGE [PACKAGE...]
Unsuspend Packages
pm unsuspend --user 0 PACKAGE [PACKAGE...]
Set Distracting Restriction
pm set-distracting-restriction --user 0 --flag hide-notifications
pm set-distracting-restriction --user 0 --flag hide-from-suggestions
Grant/Revoke Permission
pm grant --user 0 PACKAGE PERMISSION
pm revoke --user 0 PACKAGE PERMISSION
Set Permission Flags
pm set-permission-flags --user 0 PACKAGE PERMISSION [FLAGS..]
Clear Permission Flags
pm clear-permission-flags --user 0 PACKAGE PERMISSION review-required
pm clear-permission-flags --user 0 PACKAGE PERMISSION revoked-compat
pm clear-permission-flags --user 0 PACKAGE PERMISSION revoke-when-requested
pm clear-permission-flags --user 0 PACKAGE PERMISSION user-fixed
pm clear-permission-flags --user 0 PACKAGE PERMISSION user-set
Reset Permissions
pm reset-permissions
Set Permission Enforced
pm set-permission-enforced PERMISSION [true|false]
Get Privileged App Permissions
pm get-privapp-permissions TARGET-PACKAGE
Get Privileged App Deny Permissions
pm get-privapp-deny-permissions TARGET-PACKAGE
Get OEM Permissions
pm get-oem-permissions TARGET-PACKAGE
Trim Caches
pm trim-caches DESIRED_FREE_SPACE [internal|UUID]
List Users
pm list users
Create User
pm create-user [--profileOf USER_ID] [--managed] [--restricted] [--ephemeral] [--guest] [--pre-create-only] [--user-type USER_TYPE] USER_NAME
Remove User
pm remove-user [--set-ephemeral-if-in-use | --wait] USER_ID
Set User Restriction
pm set-user-restriction --user 0 RESTRICTION VALUE
Get Maximum Users
pm get-max-users
Get Maximum Running Users
pm get-max-running-users
Force Dex Optimization
pm force-dex-opt PACKAGE
Delete Dexopt
pm delete-dexopt PACKAGE
Background Dexopt Job
pm bg-dexopt-job
Cancel Background Dexopt Job
pm cancel-bg-dexopt-job
Reconcile Secondary Dex Files
pm reconcile-secondary-dex-files TARGET-PACKAGE
Dump Profiles
pm dump-profiles [--dump-classes-and-methods] TARGET-PACKAGE
Snapshot Profile
pm snapshot-profile TARGET-PACKAGE [--code-path path]
Set Home Activity
pm set-home-activity --user 0 TARGET-COMPONENT
Set Installer
pm set-installer PACKAGE INSTALLER
Get Instant App Resolver
pm get-instantapp-resolver
Set Harmful App Warning
pm set-harmful-app-warning [--user <USER_ID>] <PACKAGE> [<WARNING>]
Get Harmful App Warning
pm get-harmful-app-warning [--user <USER_ID>] <PACKAGE>
Uninstall System Updates
pm uninstall-system-updates [<PACKAGE>]
Get Module Info
pm get-moduleinfo [--all | --installed] [module-name]
Log Visibility
Enable Log Visibility
pm log-visibility --enable <PACKAGE>
Disable Log Visibility
pm log-visibility --disable <PACKAGE>
You can use the following command to retrieve the app links configuration:
| Status | Meaning |
|---|---|
none | Nothing has been recorded for this domain |
verified | The domain has been successfully verified |
approved | Force approved, usually through shell |
denied | Force denied, usually through shell |
migrated | Preserved verification from a legacy response |
restored | Preserved verification from a user data restore |
legacy_failure | Rejected by a legacy verifier, unknown reason |
system_configured | Automatically approved by the device config |
>= 1024 | Custom error code which is specific to the device verifier |
pm get-app-links [--user <USER_ID>] [<PACKAGE>]
Set App Links
| State | Description |
|---|---|
| STATE_NO_RESPONSE (0) | Reset the domains as if no response was ever recorded. |
| STATE_SUCCESS (1) | Treat the domains as successfully verified by the domain verification agent. Note that the domain verification agent can override this. |
| STATE_APPROVED (2) | Treat the domains as always approved, preventing the domain verification agent from changing them. |
| STATE_DENIED (3) | Treat the domains as always denied, preventing the domain verification agent from changing them. |
You can use the following command to set the app links state for all domains:
pm set-app-links [--package <PACKAGE>] <STATE> all
Reset App Links
pm reset-app-links [--user <USER_ID>] [<PACKAGE>]
Verify App Links
pm verify-app-links [--re-verify] [<PACKAGE>]
Set App Links User Selection
pm set-app-links-user-selection --user <USER_ID> [--package <PACKAGE>] <ENABLED> <DOMAINS>...
Set App Links Allowed
pm set-app-links-allowed --user <USER_ID> [--package <PACKAGE>] <ALLOWED> <ENABLED> <DOMAINS>...
Get App Link Owners
pm get-app-link-owners [--user <USER_ID>] [--package <PACKAGE>] [<DOMAINS>]