Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Cannot find symbol DataBindingComponent after AndroidX migration

After migrating my whole project to android x I can't get it to compile anymore.

I get 100 of following errors:

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

I don't know where to continue.

I have two problems now.

  • I only see 100 errors
  • all errors are the same and are probably hiding the real error

What I tried:

  • I have following in my projects build.gradle to increase the number of printed errors to 10000:

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

    This always worked but in this case it does not increase the errors that are printed

Any ideas what I could do next?

Additional

  • I use following

    android.enableJetifier=true
    android.useAndroidX=true
    
  • I use android studio 3.2, with kotlin 1.2.61 and 3.3.0-alpha01 gradle build tools

  • I use the 3.3.0-alpha01 gradle build tools because I also use evernote com.evernote:android-state which does not otherwise - problem is explained here: https://github.com/evernote/android-state/issues/56
like image 546
prom85 Avatar asked Sep 27 '18 20:09

prom85


2 Answers

SOLUTION - increase logged erros

In the past, following was enough in the broject's build.gradle file:

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

With kotlin, following will help:

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

REAL ISSUE

In my case I converted a class from java to kotlin with some fields like following:

@Arg
Integer someValue;

The converter created following:

@Arg
internal var someValue: Int? = null

The problem:

internal does not work with the annotation, so it failed, but the log only showed the data binding errors...

Example project build.gradle

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

like image 126
prom85 Avatar answered Oct 18 '22 22:10

prom85


I was also getting this bug after updating to androidx, tried everything suggested in a few stack overflow posts, finally updating to gradle plugin 3.3.0-beta03 worked

like image 39
enyciaa Avatar answered Oct 19 '22 00:10

enyciaa