When using the "main" build, the Kotlin build.gradle.kts needs the following format to add subfolders for Android layout .xml files (for cleaning up the project folders):
from https://developer.android.com/studio/write/add-resources#kts
//if you add another subfolder in the res/layouts/... folder, you need
//to add it to this section, relative to the build.gradle.kts file:
//so, to add subfolder 'foo', add the line:
// res.srcDir("/src/main/res/layouts/foo/")
//don't forget to add the "layout" (no 's') as a subfolder within that
//to properly populate the resource lists for any R.layout.[...] call!
sourceSets {
getByName("main") {
java {
res.srcDir("/src/main/res/layouts/xxxx/")
res.srcDir("/src/main/res/layouts/yyyy/")
res.srcDir("/src/main/res/layouts/zzzz/")
res.srcDir("/src/main/res/layouts/aaaa/")
res.srcDir("/src/main/res/layouts/bbbb/")
res.srcDir("/src/main/res/layouts/cccc/")
res.srcDir("/src/main/res/layouts/dddd/")
res.srcDir("/src/main/res/layouts/eeee/")
res.srcDir("/src/main/res/layouts/")
res.srcDir("/src/main/res/")
}
}
}