Starting March 27, 2025, we recommend using android-latest-release instead of aosp-main to build and contribute to AOSP. For more information, see Changes to AOSP.
Stay organized with collections
Save and categorize content based on your preferences.
Feature launch flags are used by Google as an approach to ensuring stable
code branches. These flags are also required for certain types of contributions
to AOSP. Before implementing feature launch flagging, determine if
a flag is necessary for your change. And, if a flag is necessary, you should
determine the type of flag to use.
Determine flag usage
To determine when to use a feature launch flag, follow these guidelines:
If you are making a change that could cause the AOSP codebase to be unstable,
such as adding a new feature or fixing a particularly complex bug, use a feature
launch flag.
Conversely, if you are making a code change that isn't apt to cause the
codebase to be unstable, such as modifying comments, you don't need to use a
feature launch flag.
Determine flag type
There are two types of flags: aconfig flags and build flags.
Aconfig flags
Aconfig flags are used to separate the execution of unreleased code from
released code during the testing and release process. Aconfig flags can be
read-write or read-only:
Read-write aconfig flags are boolean variables that you can enable (set to
true) or disable (set to false) at runtime. Use a read-write flag to test
and release changes without affecting the stability of a main branch.
Read-only aconfig flags are boolean constants that you can't change at
runtime. You can convert read-write aconfig flags to read-only aconfig flags
for code that is stable and ready to release.
Additionally, depending on the compiler you're using, when a read-only flag
is used, the code that isn't executed might be excluded
from the build. Therefore, you can use read-only flags to hide any code that
isn't ready to be part of a release.
Build flags
Build flags are build-time constants (strings) and you can't change them during
runtime. Use these flags in circumstances where you can't use aconfig flags,
such as:
You have a precompiled or prebuilt piece of code that you want to include in
the build.
You want to make changes to build system itself.
You want to put flags around dependencies to manage code size.
Content and code samples on this page are subject to the licenses described in the Content License. Java and OpenJDK are trademarks or registered trademarks of Oracle and/or its affiliates.
Last updated 2025-08-29 UTC.
[[["Easy to understand","easyToUnderstand","thumb-up"],["Solved my problem","solvedMyProblem","thumb-up"],["Other","otherUp","thumb-up"]],[["Missing the information I need","missingTheInformationINeed","thumb-down"],["Too complicated / too many steps","tooComplicatedTooManySteps","thumb-down"],["Out of date","outOfDate","thumb-down"],["Samples / code issue","samplesCodeIssue","thumb-down"],["Other","otherDown","thumb-down"]],["Last updated 2025-08-29 UTC."],[],[],null,["# Determine flag usage and type\n\nFeature launch flags are used by Google as an approach to ensuring stable\ncode branches. These flags are also required for certain types of contributions\nto AOSP. Before implementing feature launch flagging, determine if\na flag is necessary for your change. And, if a flag is necessary, you should\ndetermine the type of flag to use.\n\nDetermine flag usage\n--------------------\n\nTo determine when to use a feature launch flag, follow these guidelines:\n\n- If you are making a change that could cause the AOSP codebase to be unstable,\n such as adding a new feature or fixing a particularly complex bug, use a feature\n launch flag.\n\n- Conversely, if you are making a code change that isn't apt to cause the\n codebase to be unstable, such as modifying comments, you don't need to use a\n feature launch flag.\n\nDetermine flag type\n-------------------\n\nThere are two types of flags: *aconfig flags* and *build flags*.\n\n### Aconfig flags\n\nAconfig flags are used to separate the execution of unreleased code from\nreleased code during the testing and release process. Aconfig flags can be\nread-write or read-only:\n\n- *Read-write aconfig flags* are boolean variables that you can enable (set to\n `true`) or disable (set to `false`) at runtime. Use a read-write flag to test\n and release changes without affecting the stability of a main branch.\n\n- *Read-only aconfig flags* are boolean constants that you can't change at\n runtime. You can convert read-write aconfig flags to read-only aconfig flags\n for code that is stable and ready to release.\n\n Additionally, depending on the compiler you're using, when a read-only flag\n is used, the code that isn't executed might be excluded\n from the build. Therefore, you can use read-only flags to hide any code that\n isn't ready to be part of a release.\n\n### Build flags\n\nBuild flags are build-time constants (strings) and you can't change them during\nruntime. Use these flags in circumstances where you can't use aconfig flags,\nsuch as:\n\n- You have a precompiled or prebuilt piece of code that you want to include in the build.\n- You want to make changes to build system itself.\n- You want to put flags around dependencies to manage code size.\n\n| **Note:** Build flags have special encodings for boolean values (`false: {empty string}, true: \"true\"`)."]]