今天升級了一下android studio 發現代碼可以運行,但是打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
}
}
上面的報錯給我們提供了兩種修復的版本
方式一:修復Lint 檢查出的問題
方式二:在module 的 build.gradle添加下面代碼,這樣就可以忽略這些問題,正常打包了
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
}
}
方法二雖然很方便,但不推薦這樣忽略問題,官網是這樣說的
除了測試 Android 應用以確保其符合功能要求外,還必須確保代碼不存在結構問題。結構混亂的代碼會影響 Android 應用的可靠性和效率,增大維護代碼的難度。
Lint檢查的問題就是防止上面問題出現,所以我們下面使用方法一來解決這個問題
在上面的報錯中只提示Lint 有問題 但沒說說什麼問題。可以使用android studio 查看這些錯誤
在菜單欄中
可以全部檢查也可以指定文件夾檢查,點擊OK稍等一會就可以看到檢查結果了,然後把檢查結果中的error 解決就可以正常打包了
參考鏈接
https://developer.android.google.cn/studio/write/lint?hl=zh-CN