打包出现Lint异常

前言

这个也是最近出现的一个问题,当前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      
  }
}
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10

我按照报错下边的信息提示,在build.gradle中添加:

    lintOptions {       
  checkReleaseBuilds false                
   abortOnError false      
    }
  • 1
  • 2
  • 3
  • 4

之后再次打包,确实不再报错了,但是总觉得不踏实,既然是发现了致命的错误(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,打包成功!

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值