9

How/Where Can I find the generated code for ViewBinding?

whenever I try control+click/control+b to see the declaration, AndroidStudio just opens the XML layout.

seyed Jafari
  • 1,235
  • 10
  • 20

4 Answers4

20

The generate binding classes reside in app > build > generated > data_binding_base_class_source_out > debug > your app package > databinding

A you can see in the following screenshot all my ViewBinding classes for XML layout are inside the above path

Screeen shot of generated classes path

Somesh Kumar
  • 8,088
  • 4
  • 33
  • 49
  • @seyedJafari you need to build the project then after that, you will find it there. – Somesh Kumar Mar 04 '20 at 07:34
  • After trying everything I figured it's a problem of AndroidStudio canary4.0 updated to 4.1 and now can find it – seyed Jafari Mar 04 '20 at 07:37
  • @Somesh Kumar How do I get to the Android Studio screen you show above? In the Project section of the Tool Window, when I select "Packages" or "Project Files" I am not able to see build > generated > etc... Any thoughts? – AJW May 30 '21 at 23:43
  • 3
    @AJW You need to make sure you can build your project successfully. Go to Build > Rebuild Project. If it builds successfully you will get the above result ONLY in **Project** view and not in **Packages** or **Project Files**. – Somesh Kumar May 31 '21 at 05:02
3
  1. open terminal enter image description here

  2. type find . -iname "*binding.java"

enter image description here

ZhuGang
  • 61
  • 3
1

You can use the Ctrl + Shift + N (Go to file) to find the file with BindingImpl suffix.

beigirad
  • 4,986
  • 2
  • 29
  • 52
  • it does not find the file I have tried all the search options in AS – seyed Jafari Mar 04 '20 at 07:20
  • 2
    Navigation in AS only worked for me after I marked the app/build/generated directory as "Generated sources root" (right click on the directory > Mark directory as...) – etienne Jun 30 '21 at 08:08
0

The name of the generated class for your_layout.xml is YourLayoutBindingImpl.java. so you can find the implementation using double-shift.