ActivityMainBindingImpl cannot be found

in dataBinding pattern if u have any wrong (without any runtime error) in layout.xml or in activity ... You have not this class .. and in kotlin be sure if u add dataBinding like this :

android {
   //
        }
    }

    dataBinding {
        enabled = true
    }
}

and :

// notice that the compiler version must be the same than our gradle version
kapt 'androidx.databinding:databinding-compiler:3.2.1'

should be Ok.


Re-check your xml file there could be some issue, run the gradle task "kaptDebugkotlin" under other section & see in the logCat

An exception occurred: android.databinding.tool.util.LoggedErrorException: Found data binding errors.

enter image description here


The likely cause is an error in the data binding stage.

The data binding compiler takes layout files and generates classes to support data binding (as you note: ActivityMainBinding, ActivityMainBindingImpl; the general pattern, dear readers, is {layout}Binding and {layout}BindingImpl, where {layout} is the camel-cased name of the layout file). Errors that arise during data binding compilation prevent these support classes from being generated. This then causes the missing class error you see from the Kotlin or Java compiler.

Currently, data binding errors aren't shown in the cooked build log; to see them, switch the view to the raw compiler output. Starting around AS 3.5, data binding errors should be shown in the cooked log.

Once you locate the error message from the data binding compiler, you can fix it, or look for an answer here on how to fix it if you're not sure.