java - 错误 :(116) Error: Expected resource of type id [ResourceType]

标签 java android

当我调试我的应用程序时没有错误,但是当我生成签名应用程序时出现此错误:

   /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 found fatal errors while assembling a release target.

了解 lint

适用于 Gradle 的 Android 插件允许您使用模块级的 lintOptions {} block 配置特定的 lint 选项,例如运行或忽略哪些检查build.gradle 文件。

 lintOptions 
   {
       abortOnError false
       checkReleaseBuilds false
   }

在那之后CLEAN-REBUILD-RUN

关于java - 错误 :(116) Error: Expected resource of type id [ResourceType],我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47790360/

相关文章:

java - 在 Java 中使用 getter 方法返回私有(private)集合

java - Selenium-Java-Actions 类型错误 : rect is undefined

java - 在java中获取反射类的实例

java - 从文件路径将位图设置为 imageview 不起作用

android - 如何更改应用栏中的文字?

java - 如何在互联网连接上显示通知?

java - 字符串排序空值

尝试 listview.getChildAt() 时出现 java.lang.NullPointerException

android - 从 WorkManager API 级别 29+ 启动 Activity

android - 以编程方式从 android 转换到 miracast 接收器的步骤