【错误记录】Android Studio 编译报错 ( Execution failed for task ‘:APP_MIDI:lintVitalRelease‘. )

2023-03-30 12:04:58 浏览数 (1)

文章目录

  • 一、报错信息
  • 二、解决方案
    • 方案一
    • 方案二

一、报错信息


编译 Android 应用时 , 报如下错误 :

代码语言:javascript复制
Execution failed for task ':app:lintVitalRelease'.
> Lint found fatal errors while assembling a release target.

* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.

二、解决方案


方案一

lint 检查报错 , 报错信息输出在 build/reports/lint-results-release-fatal.xml 文件中 , 可以通过改文件中的报错信息 , 修改相关语法错误 ;

报错信息示例 :

代码语言:javascript复制
<?xml version="1.0" encoding="UTF-8"?>
<issues format="5" by="lint 4.1.0">

    <issue
        id="NotSibling"
        severity="Fatal"
        message="`@ id/button` is not a sibling in the same `RelativeLayout`"
        category="Correctness"
        priority="6"
        summary="Invalid Constraints"
        explanation="Layout constraints in a given `ConstraintLayout` or `RelativeLayout` should reference other views within the same relative layout (but not itself!)"
        errorLine1="        android:layout_below=&quot;@ id/button&quot;"
        errorLine2="        ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~">
        <location
            file="D:Applicationappsrcmainreslayoutactivity_main.xml"
            line="836"
            column="9"/>
    </issue>

</issues>

方案二

在 build.gradle 中配置 取消 lint 检查 :

代码语言:javascript复制
android{
    lintOptions {
        checkReleaseBuilds false
        abortOnError false
    }
}

0 人点赞