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.¶
Print the path to the .apk of the given PACKAGE.¶
Print various system state associated with the given PACKAGE.¶
Prints true and returns exit status 0 when the system has a FEATURE_NAME, otherwise prints false and returns exit status 1.¶
Prints all features of the system.¶
Prints all test packages; optionally only those targeting TARGET-PACKAGE.¶
Prints all system libraries.¶
List Packages¶
Prints all packages and their associated files.¶
Prints all known packages, excluding APEXes.¶
Filters and shows only disabled packages.¶
Filters and shows only enabled packages.¶
Filters and shows only system packages.¶
Filters and shows only third-party packages.¶
Shows the installer for the packages.¶
Ignored (used for compatibility with older releases).¶
Also shows the package UID.¶
Includes uninstalled packages.¶
Also shows the version code.¶
Only shows APEX packages.¶
Filters and shows packages with the given UID.¶
Only lists packages belonging to the given user.¶
Prints all known permission groups.¶
List Permissions¶
List all permissions.¶
List permissions and their groups.¶
List only system permissions.¶
List only disabled permissions.¶
List only user permissions.¶
List all staged sessions.¶
List only ready staged sessions.¶
List only session IDs of staged sessions.¶
List only parent staged sessions.¶
List Users¶
Prints the activity that resolves to the given INTENT.¶
Prints all activities that can handle the given INTENT.¶
Prints all services that can handle the given INTENT.¶
Prints all broadcast receivers that can handle the given INTENT.¶
Install package with default options for user 0¶
Install package with default options for all users¶
Install package with default options for the current user¶
Install package with the option to retain data and cache for user 0¶
Install package with the option to retain data and cache for all users¶
Install package with the option to retain data and cache for the current user¶
Install package with the option to retain only the cache for user 0¶
Install package with the option to retain only the cache for all users:¶
Install package with the option to retain only the cache for the current user¶
Install package with the option to grant all runtime permissions and retain data and cache for user 0¶
Install package with the option to grant all runtime permissions and retain data and cache for all users¶
Install package with the option to grant all runtime permissions and retain data and cache for the current user¶
Install¶
Install Location¶
Location Code | Description |
---|---|
0 | Auto |
1 | Internal Only |
2 | Prefer External |
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 |
Originating URI¶
Referrer URI¶
ABI (CPU Architecture)¶
Force SDK¶
Preload¶
Instant¶
Full Install¶
Don't Kill¶
Enable Rollback¶
Force UUID¶
Package¶
File Size¶
Install Apex Package¶
Staged Ready Timeout¶
Install Path¶
Install with Reason¶
Reason Code | Description |
---|---|
0 | Unknown |
1 | Admin Policy |
2 | Device Restore |
3 | Device Setup |
4 | User Request |
Install Create with User ID¶
To specify the user ID for the installation, you can use the following commands:
Replace USER_ID
with the desired user ID. For example, to specify the system user (ID 0), you can use:
Install Create for All Users¶
To install the package for all users on a multi-user device, you can use the following command:
Install Create for Current User¶
To install the package for the current user, you can use the following command:
install-existing¶
Install Existing Package with User ID¶
Install Existing Package as Instant App¶
Install Existing Package as Full App¶
Install Existing Package and Wait¶
Install Existing Package without Whitelisting Restricted Permissions¶
Install Write¶
Install Remove¶
Install Add Session¶
Install Commit¶
Install Abandon¶
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¶
Set Install Location to Internal Only¶
Set Install Location to Prefer External¶
Get Install Location¶
Move Package¶
Move Primary Storage¶
Uninstall Package¶
Clear Package Data¶
Enable Package or Component¶
Disable Package or Component¶
Disable User for Package or Component¶
Disable Until Used for Package or Component¶
Set Default State for Package or Component¶
Hide Package or Component¶
Unhide Package or Component¶
Suspend Packages¶
Unsuspend Packages¶
Set Distracting Restriction¶
Grant/Revoke Permission¶
Set Permission Flags¶
Clear Permission Flags¶
Reset Permissions¶
Set Permission Enforced¶
Get Privileged App Permissions¶
Get Privileged App Deny Permissions¶
Get OEM Permissions¶
Trim Caches¶
List Users¶
Create User¶
adb shell pm create-user [--profileOf USER_ID] [--managed] [--restricted] [--ephemeral] [--guest] [--pre-create-only] [--user-type USER_TYPE] USER_NAME
Remove User¶
Set User Restriction¶
Get Maximum Users¶
Get Maximum Running Users¶
Force Dex Optimization¶
Delete Dexopt¶
Background Dexopt Job¶
Cancel Background Dexopt Job¶
Reconcile Secondary Dex Files¶
Dump Profiles¶
Snapshot Profile¶
Set Home Activity¶
Set Installer¶
Get Instant App Resolver¶
Set Harmful App Warning¶
Get Harmful App Warning¶
Uninstall System Updates¶
Get Module Info¶
Log Visibility¶
Enable Log Visibility¶
Disable Log Visibility¶
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 |
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:
Reset App Links¶
Verify App Links¶
Set App Links User Selection¶
adb shell pm set-app-links-user-selection --user <USER_ID> [--package <PACKAGE>] <ENABLED> <DOMAINS>...
Set App Links Allowed¶
adb shell pm set-app-links-allowed --user <USER_ID> [--package <PACKAGE>] <ALLOWED> <ENABLED> <DOMAINS>...