1

Please Help, Cant figure out how to fix this problem I'm having. These are all the information I could give to you: my activity_main.xml:

android:paddingBottom="@dimen/activity_vertical_margin"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin"

and dimen.xml:

<dimen name="activity_horizontal_margin">activityhorizontalmargin</dimen>
<dimen name="activity_vertical_margin">activityverticalmargin</dimen>

Error log:

Error:FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':app:mergeDebugResources'.
> java.util.concurrent.ExecutionException: com.android.builder.internal.aapt.v2.Aapt2Exception: Android resource compilation failed
  Output:  C:\Users\James\MyApplications\app\build\intermediates\incremental\mergeDebugResources\merged.dir\values\values.xml:431: error: invalid dimen.
  C:\Users\James\MyApplications\app\build\intermediates\incremental\mergeDebugResources\merged.dir\values\values.xml:432: error: invalid dimen.

  Command: C:\Users\James\.gradle\caches\transforms-1\files-1.1\aapt2-3.2.1-4818971-windows.jar\84132278bf8a6c162bc0b3eae2e1efaf\aapt2-3.2.1-4818971-windows\aapt2.exe compile --legacy \
          -o \
          C:\Users\James\MyApplications\app\build\intermediates\res\merged\debug \
          C:\Users\James\MyApplications\app\build\intermediates\incremental\mergeDebugResources\merged.dir\values\values.xml
  Daemon:  AAPT2 aapt2-3.2.1-4818971-windows Daemon #2
  Output:  C:\Users\James\MyApplications\app\src\main\res\values\dimens.xml:4:5-80: AAPT: error: invalid dimen.

  C:\Users\James\MyApplications\app\src\main\res\values\dimens.xml:3:5-76: AAPT: error: invalid dimen.

  Command: C:\Users\James\.gradle\caches\transforms-1\files-1.1\aapt2-3.2.1-4818971-windows.jar\84132278bf8a6c162bc0b3eae2e1efaf\aapt2-3.2.1-4818971-windows\aapt2.exe compile --legacy \
          -o \
          C:\Users\James\MyApplications\app\build\intermediates\res\merged\debug \
          C:\Users\James\MyApplications\app\build\intermediates\incremental\mergeDebugResources\merged.dir\values\values.xml
  Daemon:  AAPT2 aapt2-3.2.1-4818971-windows Daemon #2

1 Answer 1

3

You have incorrect values in dimen.xml:

<dimen name="activity_horizontal_margin">activityhorizontalmargin</dimen>
<dimen name="activity_vertical_margin">activityverticalmargin</dimen>

it should be something like this:

<dimen name="activity_horizontal_margin">10dp</dimen>
<dimen name="activity_vertical_margin">10dp</dimen>

Please be noted that dimen is the abbreviation of dimension.

More details about it can be read at https://developer.android.com/guide/topics/resources/more-resources#Dimension

Sign up to request clarification or add additional context in comments.

2 Comments

Thank you. I fixed my dimen.
@walockdeathBringer: You're very welcome ;). Happy coding!

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.