简体   繁体   English

任务':app:mergeDebugResources'的执行失败。 错误:无效的维数

[英]Execution failed for task ':app:mergeDebugResources'. error: invalid dimen

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 : 这些是我可以提供给您的所有信息:我的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.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

You have incorrect values in dimen.xml : 您在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 . 请注意,dimen是Dimension的缩写。

More details about it can be read at https://developer.android.com/guide/topics/resources/more-resources#Dimension 有关它的更多详细信息,请访问https://developer.android.com/guide/topics/resources/more-resources#Dimension

您是否尝试在gradle.properties文件中去除aapt2

:android.enableAapt2=false

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 Android - 错误:任务执行失败':app:mergeDebugResources' - Android - Error:Execution failed for task ':app:mergeDebugResources' 错误:任务&#39;:app:mergeDebugResources&#39;的执行失败 - Error:Execution failed for task ':app:mergeDebugResources' 错误:任务“:app:mergeDebugResources”的执行失败。 - Error:Execution failed for task ':app:mergeDebugResources'. 任务&#39;:app:mergeDebugResources&#39;的错误_Execution失败 - Error _Execution failed for task ':app:mergeDebugResources' 任务“:app:mergeDebugResources”执行失败。 错误 - Execution failed for task ':app:mergeDebugResources'. Error 如何修复任务执行失败&#39;:app:mergeDebugResources&#39; - How to fix Execution failed for task ':app:mergeDebugResources' 错误:任务“:app:mergeDebugResources”执行失败。 &gt; 某些文件处理失败,请参阅日志了解构建 gradle 问题的详细信息 - Error:Execution failed for task ':app:mergeDebugResources'. > Some file crunching failed, see logs for details build gradle issues Gradle Build因“错误:任务执行失败”而崩溃:app:mergeDebugResources&#39;。 &gt; Crunching Cruncher photo.png失败了“ - Gradle Build Fails Due to “Error:Execution failed for task ':app:mergeDebugResources'. > Crunching Cruncher photo.png failed” 如何在Android Studio中修复“任务&#39;:app:mergeDebugResources执行失败”? - How to fix “Execution failed for task ':app:mergeDebugResources” in android studio? android错误:任务&#39;:app:mergeDebugResources&#39;的执行失败。 &gt; java.lang.OutOfMemoryError:无法创建新的本机线程 - android Error:Execution failed for task ':app:mergeDebugResources'. > java.lang.OutOfMemoryError: unable to create new native thread
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM