【Android】解决Lint found fatal errors while assembling a release target

Error message:

There is no problem with Android packaging in debug mode, but the following problems occur when packaging the release version:

Result graph

Insert image description here

reason

The reason for my project is that I put the official and test addresses into the code and forgot to select the address of the official environment, which caused problems when printing the official package. If you are in the same situation as me, you can check it out.

Solution

1. Directly block the lint check in the build.Gradle file.
Blocking code:

/android {
lintOptions {
checkReleaseBuilds true
// Or, if you prefer, you can continue to check for errors in release builds,
// but continue the build even when errors are found:
abortOnError true
}
}
/

2. Add a piece of code to the project file:
1. Open the lint-results-release-fatal.html file in the reports folder under the build folder under the app (open this HTML file in the browser). Everyone's project is different. , so this file may not exist. My project at that time was because the official environment address was assigned to the code, so without this file, this method would not work. The first method used is feasible. 2. Open the browser to see the details
Insert image description here
. If there is an error, just run it after correcting it. Or just select a class in the project, right-click to analyze the code globally, and there will be prompts if you find the error. Fix the bug according to the possible reasons. It is not ruled out that there will be files that can run normally, and it is possible to troubleshoot the error.
Insert image description here

See here for details

Guess you like

Origin blog.csdn.net/KJJfighting/article/details/132317355