版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/aiynmimi/article/details/89401239
前言
这个也是最近出现的一个问题,当前Android Studio的版本是3.3.2,同样的代码在3.0.1版本没有出现!所以猜测应该是3.3.2版本,可能lint的执行更加严格!Anyway,来看一下这个错误!
错误详情
在打release包的时候,出现编译错误!
Lint found fatal errors while assembling a release target.
To proceed, either fix the issues identified by lint, or modify your build script as follows: ...
android {
lintOptions {
checkReleaseBuilds false
// Or, if you prefer, you can continue to check for errors in release builds,
// but continue the build even when errors are found:
abortOnError false
}
}
我按照报错下边的信息提示,在build.gradle中添加:
lintOptions {
checkReleaseBuilds false
abortOnError false
}
之后再次打包,确实不再报错了,但是总觉得不踏实,既然是发现了致命的错误(found fatal errors),总得知道检查到了什么错误吧!
正确姿势
那么怎么去查看Lint发现的这个致命错误呢?在查阅了一些资料之后,找到在项目目录下app/build/reports/lint-results-release-fatal.html
文件,这个文件就详细描述了release时lint检测到的比较严重的结果,我们可以用浏览器打开这个文件!
我这里,明确的指出了错误的内容:The dimen “x_1” in values-1024x600 has no declaration in the base values folder; this can lead to crashes when the resource is queried in a configuration that does not match this qualifier.
指出在base values folder中没有声明dimen “x_1”,所以我在values.xml
中添加上dimen "x_1"即可!再次执行gradlew assembleRelease
,打包成功!