'Databinding generated in the wrong package
I have several modules in my project and I've renamed one of them (including the packages). This module is an Android Library module with databinding enabled.
After the renaming, the ActivityBindingImpl file is generated in the old package.
The BR and DataBinderMapperImpl files are generated in the new package like this:
module
-- java (generated)
---- old.package
------ ActivityBindingImpl
---- new.package
------ BR
------ DataBinderMappingImpl
Then I get the expected a build error:
ActivityBindingImpl.java:2: error: cannot find symbol import old.package.BR
The package in the Manifest file is correct.
I've tried to clean the project, invalidate Android Studio cache, disable/enable databinding as explained here but nothing worked.
Edit:
kapt {
useBuildCache = false
}
Also didn't help :(
Solution 1:[1]
Adding kapt "com.android.databinding:compiler:3.1.4" to the build.gradle fixed the issue. Don't know why exactly.
Solution 2:[2]
Steps
Step 1.
buildFeatures {
viewBinding false
}
Step 2. Sync your project
Step 3. Clean and rebuild your project
Step 4.
buildFeatures {
viewBinding true
}
Step 5. Again Sync your project
Step 6. Clean and rebuild your project
it's work for me!
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | Sir Codesalot |
| Solution 2 | rabi |
