Android Databinding : package does not exist
Solution 1
Thanks to Yigit!
The issue was not directly link to Android Databinding. There were a bug in the project (some variables not correctly setted)
I would recommend to use gradle with "--debug and --stacktrace" for more informations, it's helping a lot.
Solution 2
earlier my package name was "com.xyz.abc.Models" changing the package name to all small letters "Models" -> "models"
solved the issue.
Solution 3
The bug is not the DataBinding Package, it's a syntactic or logical error. For example, you have the attribute "lastName" in your POJO, but in the layout it's android:text="@{user.lastname}"
.
Check your "layout" and do Rebuild Project.
Solution 4
I am not satisfied with accepted answer, that tell you to stack trace without hints.
Here are some possible causes that lead to this problem. Check if you are not doing any of the following.
Basically Android DataBinding is not that mature still. It will fail without appropriate errors many times.
So if you have an issue like package ch.company.project.databinding does not exist"
.
Possible causes of fail:
-
First of all check your recently edited layouts xml one by one for errors (for wrong
imports
&variables
). I don't get proper error in this case usually. -
Check your data binding syntax in binding block ({...}) in layout element for errors. Always Rebuild (not Build) project after working in one layout.
-
Check your
@BindingAdapter
method having correct parameters. For exampleimageUrl
binding adapter would acceptImageView
orView
as first parameter. -
You should always Rebuild project after doing work in one layout.
-
If you are not able to find errors by above steps, then try
--debug and --stacktrace
in compile option ofFile> Settings> Build, Execution, Deployment> Compiler> Command-line Options
Solution 5
Make sure your package name start with lowercase letter. in my case issue solved after two hours of struggle
![Xero](https://i.stack.imgur.com/Wv4Xe.png?s=256&g=1)
Xero
Updated on February 05, 2022Comments
-
Xero over 2 years
I'm trying to use data-binding with Android.
I can not anymore build my project. I got this error :
"Error:(13, 46) error: package ch.company.project.databinding does not exist"
Here my
gradle
:and
And here the gradle output :
-
yigit over 8 yearsCan you share the gradle output as well? (with --debug and --stacktrace)
-
yigit over 8 yearsHere is your error: /Users/anthonybernardo/Documents/Geomatic/GeomaticReborn/app/src/main/java/ch/geomatic/geomaticreborn/Views/SearchActivity.java:69: error: cannot find symbol 10:21:38.018 [ERROR] [system.err] (SearchView) MenuItemCompat.getActionView(menu.findItem(R.id.search)); Fix it and the project should compile. If not, please provide the full output (not just the error). I want to see the tasks that are run but anyways, fixing this R.id.search should fix your compilation.
-
Xero over 8 yearsomg! I was think that it was a issue with Android Databinding... Thank you a lot!
-
-
mmm111mmm over 8 yearsThis was my problem, too. I was passing in an incorrect value into a BindingAdapter. AS2.0 didn't tell me, just the errors about not finding the package above. Fun.
-
Lucas Queiroz Ribeiro over 7 yearsThis occurs because the "=" means a two way data binding, for buttons does not makes sense but if you use that in some EditText when you change the data in the EditText the data will change in the model too.
-
Alberto M over 6 yearsthank you. Scrolling should always be the first step.
-
Sukesh Saxena over 4 yearsSolve my issue too
-
Nam Le over 4 yearsThis fixes it for me. Is this mentioned anywhere in the docs of DataBinding ?
-
ThiagoYou about 4 yearsYou really saved me sir! I was stuck for hours and nothing in the records indicated that.
-
Angus about 3 yearsI encountered the same problem and still couldn't figure it out. I am using android studio in windows machine, can you please share the command to use gradle with the --debug and --stacktrace
-
Frischling over 2 yearsWhat's funny, adding this to my build gradle seems to fix the problem
apply plugin: 'kotlin-android-extensions
-
Basit Ali over 2 yearsSolved my issue. Great @Kamlesh Sahu
-
Pishang Ujeniya over 2 yearsThanks @Caner, for me it was issue that I named a package starting with Capital Letter.
-
Balflear over 2 yearsThanks, i need it to update from Arctix Fox to Bumblebee and updating the gradle plugin to the lastest for fixing the issue with databinding package.
-
Gk Mohammad Emon about 2 yearsReally helpful answer 10+