Troubleshoot runtime resource overlays

Use this content to troubleshoot why a Runtime Resource Overlay (RRO) may not be functioning as intended in an Android Automotive implementation.

To learn more about RROs in Android, see Change the value of an app's resources at runtime. Be sure to maintain a constant vigilance on logcat output, which can provide good information about what is happening throughout the process.

Step 1: List the RROs

To list the RROs:

  1. Run the following command:

    adb shell cmd overlay list --user current

    Output like this appears:
    [ ]
    [ ]
    [ ]
  2. Verify that your RRO appears in the list. The following indicators denote RRO status:

    Indicator RRO status
    [ ] Installed and ready to be activated.
    [X] Installed and activated.
    --- Installed but contains errors.

    If your RRO is not listed under the package name of the target you want to overlay, your RRO is not installed.

Step 2: Enable and disable an RRO

If an RRO is installed:

  1. Use the following command to enable (or disable) the RRO:

    adb shell cmd overlay [enable/disable] --user current [your RRO package name]

Step 3: Confirm RRO is installed

To confirm an RRO is installed on a device or troubleshoot why the RRO was not enabled:

  1. Run the following command:

    adb shell cmd overlay dump [your RRO package name]

    Output such as that below appears: {
      mUserId................: 0
      mTargetOverlayableName.: car-ui-lib
      mBaseCodePath..........: /product/overlay/googlecarui-com-android-car-rotaryplayground/googlecarui-com-android-car-rotaryplayground.apk
      mState.................: STATE_MISSING_TARGET
      mIsEnabled.............: true
      mIsMutable.............: true
      mPriority..............: 10
      mCategory..............: BypassIdMapV1
    } {
      mUserId................: 10
      mTargetOverlayableName.: car-ui-lib
      mBaseCodePath..........: /product/overlay/googlecarui-com-android-car-rotaryplayground/googlecarui-com-android-car-rotaryplayground.apk
      mState.................: STATE_MISSING_TARGET
      mIsEnabled.............: true
      mIsMutable.............: true
      mPriority..............: 10
      mCategory..............: BypassIdMapV1
  2. Identify the user (or users) who've installed the RRO. In the example above, the RRO is available for user 0 and user10 (see the values for mUserId in the top code block).

  3. To enable (or disable) the RRO for the desired user, go to Step 2.

  4. To check the value of mState:

    • STATE_ENABLED and STATE_ENABLED_IMMUTABLE. The RRO is enabled and applied to your target.

    • STATE_MISSING_TARGET. Your target is not installed.

    • STATE_NO_IDMAP. Something is wrong with the way the AndroidManifest.xml, overlays.xml, or overlayable.xml files are set up. Use adb logcat to run the logs and search for the keyword idmap to identify the error. See steps 4 & 5

    • STATE_UNKNOWN. Something is wrong with OverlayManagerService.

Step 4: Check AndroidManifest.xml

To verify AndroidManifest.xml:

  1. Check targetName and targetPackage.

    android:targetName should have the same value of the overlayable group defined in the target application. This is required only when targeting an overlay.

    android:targetPackage is always required and should contain the package name of the target application.

  2. Check that your RRO is static (or not). Static RROs are enabled by default at boot time. Dynamic RROs aren't enabled by default at boot. Additional ways of enabling dynamic RROs are provided in Change the value of an app's resources at runtime.

  3. Check the priority of your static RRO (dynamic RRO priority is always set to Integer.MAX_VALUE and the order in which they're applied is based on when they are enabled).

    Multiple RROs may apply to the same target. RROs with a higher priority are applied last. On a scale of 0 to 10, 10 is highest and 0 is lowest.

Step 5: Check overlays.xml

This check applies only to Android 11 (and higher).

  1. Check overlays.xml to confirm all resources you intend to overlay are defined in this file. For example, consider the followingoverlays.xml:

        <item target="string/app_name" value="@string/overlaid_app_name" />
  2. You must ensure that a:

    • string resource with the name app_name exists in the target app.
    • string resource with the name overlaid_app_name exists in your RRO.
  3. If your target has an overlayable.xml file, make sure app_name is contained in that file. Make sure you use the correct targetName in your AndroidManifest.xml file (Step 4).

    For example:

    <item target="layout/car_ui_base_layout_toolbar" value="@layout/car_ui_base_layout_toolbar" />
    <item target="id/car_ui_toolbar_background" value="@id/car_ui_toolbar_background" />
    <item target="attr/layout_constraintTop_toBottomOf" value="@attr/layout_constraintTop_toBottomOf" />

Step 6: Dump the idmap

At this stage, all issues with your RRO should be resolved. Next, dump the idmap of your RRO to learn how a resource is being resolved and why it's resolving to a different value than you expect.

  1. To find the path to the idmap on your device:

    adb shell
    ls data/resource-cache
  2. To dump the content of that file:

    idmap2 dump --idmap-path [path to your RRO idmap file]

    The output appears similar to the following. The output displays which ID from your RRO is mapped to which ID in your target as well as the name of the overlaid resource.

    target apk path : /system/priv-app/CarMediaApp/CarMediaApp.apk
    overlay apk path : /product/overlay/googlecarui-com-android-car-media/googlecarui-com-android-car-media.apk
    0x7f040008 -> 0x7f010000 bool/car_ui_toolbar_logo_fills_nav_icon_space
    0x7f040009 -> 0x7f010001 bool/car_ui_toolbar_nav_icon_reserve_space
    0x7f04000b -> 0x7f010002 bool/car_ui_toolbar_tab_flexible_layout
    0x7f04000c -> 0x7f010003 bool/car_ui_toolbar_tabs_on_second_row
    0x7f09006c -> 0x7f020000 id/car_ui_base_layout_content_container
    0x7f090073 -> 0x7f020001 id/car_ui_recycler_view
    0x7f090074 -> 0x7f020002 id/car_ui_scroll_bar
    0x7f090075 -> 0x7f020003 id/car_ui_scrollbar_page_down
    0x7f090076 -> 0x7f020004 id/car_ui_scrollbar_page_up
    0x7f090077 -> 0x7f020005 id/car_ui_scrollbar_thumb
    0x7f090078 -> 0x7f020006 id/car_ui_scrollbar_track
    0x7f09007a -> 0x7f020007 id/car_ui_toolbar_background
    0x7f09007e -> 0x7f020008 id/car_ui_toolbar_logo
    0x7f090084 -> 0x7f020009 id/car_ui_toolbar_menu_items_container
    0x7f090085 -> 0x7f02000a id/car_ui_toolbar_nav_icon
    0x7f090086 -> 0x7f02000b id/car_ui_toolbar_nav_icon_container
    0x7f090087 -> 0x7f02000c id/car_ui_toolbar_progress_bar
    0x7f090089 -> 0x7f02000d id/car_ui_toolbar_row_separator_guideline
    0x7f09008d -> 0x7f02000e id/car_ui_toolbar_search_view_container
    0x7f09008f -> 0x7f02000f id/car_ui_toolbar_subtitle
    0x7f090092 -> 0x7f020010 id/car_ui_toolbar_tabs
    0x7f090093 -> 0x7f020011 id/car_ui_toolbar_title
    0x7f090094 -> 0x7f020012 id/car_ui_toolbar_title_container
    0x7f090095 -> 0x7f020013 id/car_ui_toolbar_title_logo
    0x7f090096 -> 0x7f020014 id/car_ui_toolbar_title_logo_container
    0x7f0c0024 -> 0x7f030000 layout/car_ui_base_layout_toolbar
    0x7f0c0035 -> 0x7f030001 layout/car_ui_recycler_view
    0x7f0c0038 -> 0x7f030002 layout/car_ui_toolbar
    0x7f0c003f -> 0x7f030003 layout/car_ui_toolbar_two_row

Use the following command to look up a specific resource to see how they're mapped:

adb shell cmd overlay lookup --verbose --user 10

The output is the final value of the resource:


You can also dump your layout files from your apks to view the resolved IDs to match the above output:

aapt2 dump xmltree $OUT/system/priv-app/sharedlibraryclient/sharedlibraryclient.apk --file res/layout/activity_main.xml

Output such as the following is returned:

N: android= (line=2)
  N: app= (line=2)
    N: lib= (line=2)
      E: androidx.constraintlayout.widget.ConstraintLayout (line=2)
          E: TextView (line=19)
          E: (line=28)
            A:"HelloWorld!" (Raw: "HelloWorld!")
          E: (line=34)
            A:"HelloWorld!!" (Raw: "HelloWorld!!")