当我调试我的应用程序时没有错误,但是当我生成签名应用程序时出现此错误:
/Users/dariobrun/Documents/AndroidStudioProjects/PGNChessEditor/app/src/main/java/it/dario/brun/pgnchesseditor/app/PannelloScacchiera.java:116: Error: Expected resource of type id [ResourceType]
black.setId(1);
~
Explanation for issues of type "ResourceType":
Ensures that resource id's passed to APIs are of the right type; for
example, calling Resources.getColor(R.string.name) is wrong.
1 errors, 0 warnings
FAILED
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':app:lintVitalRelease'.
> 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
}
}
...
* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.
* Get more help at https://help.gradle.org
BUILD FAILED in 3s
25 actionable tasks: 3 executed, 22 up-to-date
这是生成错误的java代码:
black=new RadioButton(context);
black.setTextSize(TypedValue.COMPLEX_UNIT_PX,context.getResources().getDimension(R.dimen.pannello_size));
black.setText(getResources().getString(R.string.moveblack));
black.setId(1);
但即使它说“构建失败”已生成签名的apk并且它工作正常。 那么,发生了什么?我应该担心吗?
答案 0 :(得分:0)
Lint在组装释放目标时发现致命错误。
了解lint
Gradle的Android插件允许您使用模块级lintOptions {}
中的 build.gradle
块来配置某些lint选项,例如要运行或忽略的检查文件。
lintOptions
{
abortOnError false
checkReleaseBuilds false
}
之后 CLEAN-REBUILD-RUN
。