代码之家  ›  专栏  ›  技术社区  ›  prom85

在AndroidX迁移后找不到symbol DataBindingComponent

  •  3
  • prom85  · 技术社区  · 7 年前

    我得到100个以下错误:

    e: M:\tmp\EverywhereLauncher\app\generated\data_binding_base_class_source_out\devWithoutTestWithAccessibilityDebug\dataBindingGenBaseClassesDevWithoutTestWithAccessibilityDebug\out\com\my\app\databinding\ActivityMainBinding.java:52: error: cannot find symbol
          @Nullable ViewGroup root, boolean attachToRoot, @Nullable DataBindingComponent component) {
                                                                    ^
      symbol:   class DataBindingComponent
      location: class ActivityMainBinding
    

    我现在有两个问题。

    • 我只看到100个错误
    • 所有的错误都是相同的,可能隐藏了真正的错误

    我尝试的是:

    • build.gradle 要将打印错误数增加到10000:

      gradle.projectsEvaluated {
              tasks.withType(JavaCompile) {
                  options.compilerArgs << "-Xmaxerrs" << "10000"
              }
          }
      

      这始终有效,但在这种情况下,不会增加打印的错误

    你知道我下一步能做什么吗?

    • 我使用下列命令

      android.enableJetifier=true
      android.useAndroidX=true
      
    • 我用安卓工作室 3.2 ,与科特林 1.2.61 3.3.0-alpha01 gradle构建工具

    • 3.3.0-字母01 gradle构建工具,因为我也使用evernote com.evernote:android-state 否则,问题就解释如下: https://github.com/evernote/android-state/issues/56
    2 回复  |  直到 7 年前
        1
  •  5
  •   prom85    7 年前

    解决方案-增加记录的错误

    在过去,以下是足够的项目的 build.gradle

    gradle.projectsEvaluated {
        tasks.withType(JavaCompile.class) {
            options.compilerArgs << "-Xmaxerrs" << "10000"
        }
    }
    

    对于kotlin,以下内容将有所帮助:

    afterEvaluate {
        if (project.plugins.hasPlugin("kotlin-kapt")) {
            kapt {
                javacOptions {
                    option("-Xmaxerrs", 10000)
                }
            }
        }
    }
    

    真正的问题

    在我的例子中,我将一个类从java转换为kotlin,其中包含如下字段:

    @Arg
    Integer someValue;
    

    转换器创建了以下内容:

    @Arg
    internal var someValue: Int? = null
    

    问题是:

    internal

    构建.gradle

    https://gist.github.com/MFlisar/eca8ae6c2e6a619913ab05d503a4368f

        2
  •  1
  •   enyciaa    7 年前

    在升级到androidx之后,我也遇到了这个bug,在一些堆栈溢出帖子中尝试了所有建议,最后升级到gradleplugin3.3.0-beta03成功了

    推荐文章