Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Android databinding swallows errors from other compilers

If there are any errors during compilation, the databinding classes arent generated - and as such, I get a ton of errors like this:

  symbol:   class DataBindingComponent
  location: class TrainingActivityCompletedSetBinding
  e: S:\ProjectLocation\TrainingActivityCompletedSetBinding.java:60: error: cannot find symbol
  @Nullable DataBindingComponent component)

The problem is that the compilation error isnt related to databinding at all, and as such I have no idea whats actually causing it - and I have to manually dig into the files to find the issue.

In the example above, I just omitted @Inject from a constructor that requires it. Itd be lovely to see the error message from Dagger in this case so that I can find it immediately, rather than having to dig into all the projects classes to find it manually.

Any help would be greatly appreciated!


Both Android Studio & Databinding is on version 3.1.3 currently, the error has been there since 3.0 at least.

Using Kotlin V1.2.41, and kapt for generating code.

Tried increasing the max number of errors the compiler would show, unfortunately no difference.

Temporarily, a workaround is to simply disable databinding V2: android.databinding.enableV2=true in gradle.properties. Still open to a better solution though.

like image 255
zoltish Avatar asked Jun 08 '18 07:06

zoltish


2 Answers

Cannot write a comment, so I'll write it here. Probably you wanted to say to add a line like this: android.databinding.enableV2=false, so it'll work right.

like image 71
Aqluse Avatar answered Nov 20 '22 18:11

Aqluse


I see that you said that you tried increasing the max number of errors that the compiler would show, but in case it helps others who find their way here:

Instead of disabling V2 databinding, you can follow this forum post which demonstrates how to extend the number of displayed errors. This fixed my issue without disabling the V2 each time.

This fixed my problem even though the number of errors I was shown wasn't a conspicuously round number, so I'm not sure how the counting works.

https://github.com/google/dagger/issues/306

like image 27
Squimon Avatar answered Nov 20 '22 19:11

Squimon