4

I got the very weird problem, I have two branches and working fine separately. after the merge, All conflicts are resolved carefully many times. But every time we run the project this 3 error will come and No stack trace. T

  1. error: cannot find symbol class DataBindingComponent

  2. error: cannot find symbol class DaggerLoginComponent

  3. Caused by: org.gradle.api.internal.tasks.compile.CompilationFailedException: Compilation failed; see the compiler error output for details.

There is something wrong that stop annotation processor to stop compilation but we didn't find any reason However we checked all the files manually but Not know How we can debug the issue and Identify the root cause of the issue. Anyone who know how we can track why annotation processor is not generating the class.

We have tried listed methods.

  1. Clean -> Rebuild -> Invalidate Restart -> Delete all temporary files.

  2. run build with this command ./gradlew clean assemble --stacktrace --debug

  3. checked every resource and java files manually to find the issue.

We have used below library

  1. lombok 1.16.20, databinding , dagger 2.16 that are using annotation processor

We have conflict in dimen, string and style files. that are resolve very carefully.

If need any more info I would provide.


Updated: Finally get a solution There was a private static import in other class that causes this problem Make Sure You don't have any java compiler issue, Even small syntax issue will not compile your binding and I don't know why the error is not printing in logcat. Hope It will resolve in the updated android studio.


Nitin Jain
  • 1,314
  • 11
  • 15

3 Answers3

2

This is most weird problem that i faced before this month. First of all Data Binding is not as mature that it show you all errors with reach point in Error Logs.

However there are some issues that are not caught by lint and lead to errors in all classes related to binding.

Causes:

  • When there is a field defined in layout component binding that is not available in your model class.
  • When you have some invalid import in your data binding layout.

Solution

  1. Check your layouts first for invalid imports. Because that will not show in error log.
  2. If you don't find anything, then check your all layouts carefully for the missing model fields, If there is some field not present in model class, and used in layout then you will not get appropriate error.
  3. If this does not help then check your Binding Component names are correct. Because if your partner renamed a layout then you should change its relevant LayoutBinding name in Activity or Fragment.

These solution helped me always to overcome this issue.

Khemraj Sharma
  • 57,232
  • 27
  • 203
  • 212
2

Adding up to comments, both times this happened to me, it was related to dagger.

  • unresolved import in a dagger module class. Spent 4 hours to find this
  • @Inject annotation on a class that was made abstract. Spent 2 days to find this

The workflow into knowing W*F is wrong, is:

  • in a small project, inspecting all your classes and layouts might be a viable choice
  • if you can, go back in commits to reach the last working point, and see from there. This is almost useless advice, because this nasty thing typically happens when you are in the middle of some kind of refactoring
  • create a destructive branch & do whatever is possible to use the old databinding compiler, android.databinding.enableV2=false. Doing this might require you to remove modules, remove new features that you were using (e.g. experimental databinding in non-feature modules), probably downgrade AGP. But it's worth it, because the old databinding compiler will actually tell you the error instead of this cannot find symbol mess.

Good luck with this exhausting process, and if you can, please file a bug report to databinding guys.

natario
  • 24,954
  • 17
  • 88
  • 158
0

Renaming the xml files to another name and check if binding works once it works rename it back to the one that was used. Hope this may help you

InsaneCat
  • 2,115
  • 5
  • 21
  • 40