Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Databinding class not generated for multiple layout folders

In Android studio 3.6, after creating new project, I am not able to created binding generated class for multiple folders.

I have multiple layout folders:

res/layout
res/layouts/dashboard
res/layouts/notifications

I am able to created binding class for

res/layout

but its not working for other layout folders.

App gradle file:

dataBinding{
        enabled = true
    }
    compileOptions {
        sourceCompatibility JavaVersion.VERSION_1_8
        targetCompatibility JavaVersion.VERSION_1_8
    }
    kotlinOptions {
        jvmTarget = "1.8"
    }
    sourceSets {
        main {
            manifest.srcFile 'src/main/AndroidManifest.xml'
            java.srcDirs = ['src/main/java']
            res.srcDirs =
                    [
                            'src/main/res/layouts/notification',
                            'src/main/res/layout/dashboard',
                            'src/main/res/layouts',
                            'src/main/res/layout',
                            'src/main/res'
                    ]
            assets.srcDirs = ['src/main/assets', 'src/main/assets/']
        }
    }

Resource folder structure:

enter image description here

I have attached sample project which I have created in android studio 3.6. Source code link

like image 984
Mehta Avatar asked Nov 07 '22 09:11

Mehta


1 Answers

It's a bug in android studio, It has been fixed in android studio 4.0 beta and 4.1 canary. And google will release hotfix for 3.6 to fix it.

like image 65
SungHwan Avatar answered Nov 14 '22 21:11

SungHwan