Issue
Im now use viewBinding with kotlin.
here is my build.gradle
enable ViewBinding and has auto import ViewBinding dependency.
but Android Studio still show error like this
but I can build and run with no problem.
and if I add viewBinding in dependencies,then the error gone.
Does anyone know why?
UPDATE:
I know why. I'm use AndroidX,the IDE say can not access 'android.viewbinding.ViewBinding', but my dependencies is AndroidX, it is 'androidx.viewbinding.ViewBinding', package name changed.
SOLUTION: add android.useAndroidX=true to project gradle.properties file.
global gradle.properties setting not work,don't know why.
Solution
Facing same issue exact error yesterday. Solution work for me is
- Step 1- Remove .Idea Folder
- Step 2- Close android studio
- Step 3- Reopen android studio with same project path (This will genarate new .Idea folder)
and Error is gone
Making sure
- android.useAndroidX=true. inside gradle.properties file
- inside app build.gradle
buildFeatures { viewBinding true }
- Always Use folder structure with samll case latter only class name is allowed to be Uppercase
- If you are using any Copyright-Comment at top of xml or Layout tag without variable tag or we can say without any data then remove that and try to clean/rebuild project
Answered By - sushant gosavi
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.