skip to Main Content

I am trying to create an application for Android on Android studio for widget.

Every time I try to run my app on emulator, I receive this error
AAPT: error: resource android:dimen/system_app_widget_internal_padding not found.

I have tried re-installing android studio, but it did not work.

v31themes.xml

<?xml version="1.0" encoding="utf-8"?>
<resources>
    <!--
    Having themes.xml for v31 variant because @android:dimen/system_app_widget_background_radius
     and @android:dimen/system_app_widget_internal_padding requires API level 31
    -->
    <style name="Theme.MyApplication.AppWidgetContainerParent" parent="@android:style/Theme.DeviceDefault.DayNight">
        <item name="appWidgetRadius">@android:dimen/system_app_widget_background_radius</item>
        <item name="appWidgetPadding">@android:dimen/system_app_widget_internal_padding</item>
        <item name="appWidgetInnerRadius">@android:dimen/system_app_widget_inner_radius</item>
    </style>
</resources>

2

Answers


  1. I ran into the same issue. I am not an professional Android developer, so this is likely my fault. To solve this I simply deleted the set value "system_app_widget_internal_padding" in appWidgetPadding and replaced it with a hardcoded numerical value. In my case, 3px.

    This isn’t the correct solution more than likely. The values set appear to be part of "Material You" which lets your widget adopt the same look as the user’s selected theme. However, I don’t know if I did something wrong that got me to here or if it is an upstream issue with Android Studio. Regardless, this let’s me keep moving forward.

    Login or Signup to reply.
  2. When using Android Studio’s App Widget template to create a widget, multiple files and resources are created.
    Two of the themes files contain the following line:

    <item name="appWidgetPadding">@android:dimen/system_app_widget_internal_padding</item>

    When building, the system_app_widget_internal_padding dimens isn’t found.
    The reason is because it was removed (or actually renamed, as you can see here). Probably this was supposed to be exposed in earlier betas of Android S and was later on removed.

    The easiest solution is to use the value directly, like the following:

    <item name="appWidgetPadding">16dp</item>

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search