![](/img/trans.png)
[英]Error: Expected resource of type string [ResourceType] // about.getComLogo().toString()
[英]Error:(116) Error: Expected resource of type id [ResourceType]
当我调试我的应用程序时没有错误,但是当我生成签名的应用程序时却出现此错误:
/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,并且工作正常。 那么,发生了什么事? 我应该担心吗?
Lint在组装发布目标时发现了致命错误。
阅读有关lint
适用于Gradle的Android插件允许您使用模块级build.gradle
文件中的lintOptions {}
块配置某些lint选项,例如运行或忽略的检查。
lintOptions
{
abortOnError false
checkReleaseBuilds false
}
之后,执行CLEAN-REBUILD-RUN
。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.