【问题标题】:FAILURE: Build failed with an exception,Android resource compilation failedFAILURE:构建失败并出现异常,Android资源编译失败
【发布时间】:2020-06-24 20:56:23
【问题描述】:
<Button
        android:layout_width="300dp"
        android:layout_height="wrap_content"
        android:text="Show"
        android:background="@drawable/back"
        app:layout_constraintBottom_toBottomOf="parent"
        app:layout_constraintLeft_toLeftOf="parent"
        app:layout_constraintRight_toRightOf="parent"
        app:layout_constraintTop_toTopOf="parent" />

当我运行此代码时,我显示此错误: FAILURE:构建失败并出现异常。

  • 出了什么问题: 任务 ':app:mergeDebugResources' 执行失败。

    执行 com.android.build.gradle.internal.tasks.Workers$ActionFacade 时发生故障 Android资源编译失败

【问题讨论】:

    标签: android


    【解决方案1】:

    在 Android Studio 中试试这个

    File > Invalidate Caches/Restart...
    

    再见。

    【讨论】:

    • 您还有更多日志吗?我需要看看。
    • E/UsbPortManager: connectToProxy: usb hal 服务未找到。服务是否启动失败? java.util.NoSuchElementException
    • E/PowerManagerService: 无法读取 last_reboot_reason 文件 java.io.FileNotFoundException: /data/misc/reboot/last_reboot_reason (没有这样的文件或目录)
    【解决方案2】:

    合并应用程序本身就说明了问题。您的编译器无法合并,因为缺少某些资源。在您的情况下,我看到您按钮上的文本是哈希编码的,这意味着没有为其存储字符串资源。只需在文本处按 alt + Enter 即可生成资源

    <Button
        android:layout_width="300dp"
        android:layout_height="wrap_content"
        android:text="@string/show" <!--THE STRING RESOURCE.-->
        android:background="@drawable/back"
        app:layout_constraintBottom_toBottomOf="parent"
        app:layout_constraintLeft_toLeftOf="parent"
        app:layout_constraintRight_toRightOf="parent"
        app:layout_constraintTop_toTopOf="parent" />
    

    【讨论】:

      猜你喜欢
      • 2022-07-20
      • 1970-01-01
      • 2018-07-28
      • 2018-10-22
      • 2018-10-29
      • 2020-06-13
      • 2021-09-24
      • 2016-05-18
      相关资源
      最近更新 更多