title: android studio databinding error Unresolved reference: databinding
body: <p>I am getting this error when trying to bind .xml layout into .kt files.
  This is my attempt on creating an app with Instant App support feature</p>
  
  <pre><code>Error:10:35:11.151 [ERROR] [org.gradle.api.Task] e: ./../feature/src/main/java/my/${projectname}/${projectname}/feature/view/splash/fragment/LandingFragment.kt: (14, 37): Unresolved reference: databinding
  10:35:11.154 [ERROR] [org.gradle.api.Task] e: ./../feature/src/main/java/my/${projectname}/${projectname}/feature/view/splash/fragment/LandingFragment.kt: (22, 42): Unresolved reference: FragmentLandingBinding
  10:35:11.379 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter] 
  10:35:11.380 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter] FAILURE: Build failed with an exception.
  10:35:11.380 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter] 
  10:35:11.380 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter] * What went wrong:
  10:35:11.380 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter] Execution failed for task ':feature:compileDebugKotlin'.
  10:35:11.380 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter] &gt; Compilation error. See log for more details
  10:35:11.380 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter] 
  10:35:11.380 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter] * Try:
  10:35:11.380 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter]  Run with --scan to get full insights.
  10:35:11.381 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter] 
  10:35:11.381 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter] * Exception is:
  10:35:11.381 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter] org.gradle.api.tasks.TaskExecutionException: Execution failed for task ':feature:compileDebugKotlin'.
  10:35:11.381 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter]   at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.executeActions(ExecuteActionsTaskExecuter.java:100)
  10:35:11.382 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter]   at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.execute(ExecuteActionsTaskExecuter.java:70)
  10:35:11.382 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter]   at org.gradle.api.internal.tasks.execution.OutputDirectoryCreatingTaskExecuter.execute(OutputDirectoryCreatingTaskExecuter.java:51)
  10:35:11.382 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter]   at org.gradle.api.internal.tasks.execution.SkipUpToDateTaskExecuter.execute(SkipUpToDateTaskExecuter.java:62)
  10:35:11.383 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter]   at org.gradle.api.internal.tasks.execution.ResolveTaskOutputCachingStateExecuter.execute(ResolveTaskOutputCachingStateExecuter.java:54)
  10:35:11.383 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter]   at org.gradle.api.internal.tasks.execution.ValidatingTaskExecuter.execute(ValidatingTaskExecuter.java:60)
  10:35:11.383 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter]   at org.gradle.api.internal.tasks.execution.SkipEmptySourceFilesTaskExecuter.execute(SkipEmptySourceFilesTaskExecuter.java:97)
  10:35:11.383 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter]   at org.gradle.api.internal.tasks.execution.CleanupStaleOutputsExecuter.execute(CleanupStaleOutputsExecuter.java:87)
  10:35:11.383 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter]   at org.gradle.api.internal.tasks.execution.ResolveTaskArtifactStateTaskExecuter.execute(ResolveTaskArtifactStateTaskExecuter.java:52)
  10:35:11.383 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter]   at org.gradle.api.internal.tasks.execution.SkipTaskWithNoActionsExecuter.execute(SkipTaskWithNoActionsExecuter.java:52)
  10:35:11.383 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter]   at org.gradle.api.internal.tasks.execution.SkipOnlyIfTaskExecuter.execute(SkipOnlyIfTaskExecuter.java:54)
  10:35:11.384 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter]   at org.gradle.api.internal.tasks.execution.ExecuteAtMostOnceTaskExecuter.execute(ExecuteAtMostOnceTaskExecuter.java:43)
  10:35:11.384 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter]   at org.gradle.api.internal.tasks.execution.CatchExceptionTaskExecuter.execute(CatchExceptionTaskExecuter.java:34)
  10:35:11.384 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter]   at org.gradle.execution.taskgraph.DefaultTaskGraphExecuter$EventFiringTaskWorker$1.run(DefaultTaskGraphExecuter.java:248)
  10:35:11.384 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter]   at org.gradle.internal.progress.DefaultBuildOperationExecutor$RunnableBuildOperationWorker.execute(DefaultBuildOperationExecutor.java:336)
  10:35:11.384 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter]   at org.gradle.internal.progress.DefaultBuildOperationExecutor$RunnableBuildOperationWorker.execute(DefaultBuildOperationExecutor.java:328)
  10:35:11.384 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter]   at org.gradle.internal.progress.DefaultBuildOperationExecutor.execute(DefaultBuildOperationExecutor.java:199)
  10:35:11.384 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter]   at org.gradle.internal.progress.DefaultBuildOperationExecutor.run(DefaultBuildOperationExecutor.java:110)
  10:35:11.384 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter]   at org.gradle.execution.taskgraph.DefaultTaskGraphExecuter$EventFiringTaskWorker.execute(DefaultTaskGraphExecuter.java:241)
  10:35:11.385 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter]   at org.gradle.execution.taskgraph.DefaultTaskGraphExecuter$EventFiringTaskWorker.execute(DefaultTaskGraphExecuter.java:230)
  10:35:11.385 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter]   at org.gradle.execution.taskgraph.DefaultTaskPlanExecutor$TaskExecutorWorker.processTask(DefaultTaskPlanExecutor.java:123)
  10:35:11.385 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter]   at org.gradle.execution.taskgraph.DefaultTaskPlanExecutor$TaskExecutorWorker.access$200(DefaultTaskPlanExecutor.java:79)
  10:35:11.385 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter]   at org.gradle.execution.taskgraph.DefaultTaskPlanExecutor$TaskExecutorWorker$1.execute(DefaultTaskPlanExecutor.java:104)
  10:35:11.385 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter]   at org.gradle.execution.taskgraph.DefaultTaskPlanExecutor$TaskExecutorWorker$1.execute(DefaultTaskPlanExecutor.java:98)
  10:35:11.385 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter]   at org.gradle.execution.taskgraph.DefaultTaskExecutionPlan.execute(DefaultTaskExecutionPlan.java:626)
  10:35:11.385 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter]   at org.gradle.execution.taskgraph.DefaultTaskExecutionPlan.executeWithTask(DefaultTaskExecutionPlan.java:581)
  10:35:11.385 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter]   at org.gradle.execution.taskgraph.DefaultTaskPlanExecutor$TaskExecutorWorker.run(DefaultTaskPlanExecutor.java:98)
  10:35:11.385 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter]   at org.gradle.internal.concurrent.ExecutorPolicy$CatchAndRecordFailures.onExecute(ExecutorPolicy.java:63)
  10:35:11.386 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter]   at org.gradle.internal.concurrent.ManagedExecutorImpl$1.run(ManagedExecutorImpl.java:46)
  10:35:11.386 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter]   at org.gradle.internal.concurrent.ThreadFactoryImpl$ManagedThreadRunnable.run(ThreadFactoryImpl.java:55)
  10:35:11.386 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter] Caused by: org.gradle.api.GradleException: Compilation error. See log for more details
  10:35:11.386 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter]   at org.jetbrains.kotlin.gradle.tasks.TasksUtilsKt.throwGradleExceptionIfError(tasksUtils.kt:8)
  10:35:11.386 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter]   at org.jetbrains.kotlin.gradle.tasks.KotlinCompile.processCompilerExitCode(Tasks.kt:415)
  10:35:11.386 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter]   at org.jetbrains.kotlin.gradle.tasks.KotlinCompile.callCompiler$kotlin_gradle_plugin(Tasks.kt:389)
  10:35:11.386 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter]   at org.jetbrains.kotlin.gradle.tasks.KotlinCompile.callCompiler$kotlin_gradle_plugin(Tasks.kt:251)
  10:35:11.386 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter]   at org.jetbrains.kotlin.gradle.tasks.AbstractKotlinCompile.execute(Tasks.kt:215)
  10:35:11.386 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter]   at org.gradle.internal.reflect.JavaMethod.invoke(JavaMethod.java:73)
  10:35:11.387 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter]   at org.gradle.api.internal.project.taskfactory.IncrementalTaskAction.doExecute(IncrementalTaskAction.java:46)
  10:35:11.387 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter]   at org.gradle.api.internal.project.taskfactory.StandardTaskAction.execute(StandardTaskAction.java:39)
  10:35:11.387 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter]   at org.gradle.api.internal.project.taskfactory.StandardTaskAction.execute(StandardTaskAction.java:26)
  10:35:11.387 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter]   at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter$1.run(ExecuteActionsTaskExecuter.java:121)
  10:35:11.387 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter]   at org.gradle.internal.progress.DefaultBuildOperationExecutor$RunnableBuildOperationWorker.execute(DefaultBuildOperationExecutor.java:336)
  10:35:11.387 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter]   at org.gradle.internal.progress.DefaultBuildOperationExecutor$RunnableBuildOperationWorker.execute(DefaultBuildOperationExecutor.java:328)
  10:35:11.387 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter]   at org.gradle.internal.progress.DefaultBuildOperationExecutor.execute(DefaultBuildOperationExecutor.java:199)
  10:35:11.388 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter]   at org.gradle.internal.progress.DefaultBuildOperationExecutor.run(DefaultBuildOperationExecutor.java:110)
  10:35:11.388 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter]   at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.executeAction(ExecuteActionsTaskExecuter.java:110)
  10:35:11.388 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter]   at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.executeActions(ExecuteActionsTaskExecuter.java:92)
  10:35:11.388 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter]   ... 29 more
  10:35:11.388 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter] 
  10:35:11.388 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter] 
  10:35:11.388 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter] * Get more help at https://help.gradle.org
  10:35:11.388 [ERROR] [org.gradle.internal.buildevents.BuildResultLogger] 
  10:35:11.389 [ERROR] [org.gradle.internal.buildevents.BuildResultLogger] BUILD FAILED in 13s
  </code></pre>
  
  <p>This is my build.gradle(Project: projectname)</p>
  
  <pre><code>// Top-level build file where you can add configuration options common to all sub-projects/modules.
  
  buildscript {
      ext.versions = [
              'kotlin_version' : '1.2.21',
              'anko_version' : '0.10.4',
              'glide_version' : '4.5.0',
              'android_plugin_version' : '3.1.0-alpha06'
  
      ]
      repositories {
          google()
          jcenter()
          maven {
              url 'https://maven.google.com/'
          }
      }
      dependencies {
          classpath "com.android.tools.build:gradle:$versions.android_plugin_version"
          classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$versions.kotlin_version"
  
          // NOTE: Do not place your application dependencies here; they belong
          // in the individual module build.gradle files
      }
  }
  
  allprojects {
      repositories {
          google()
          jcenter()
          maven {
              url 'https://maven.google.com/'
          }
      }
  }
  
  task clean(type: Delete) {
      delete rootProject.buildDir
  }
  </code></pre>
  
  <p>my build.gradle(Module:app)</p>
  
  <pre><code>apply plugin: 'com.android.application'
  
  apply plugin: 'kotlin-kapt'
  
  android {
      compileSdkVersion 27
  
  
      defaultConfig {
          applicationId "application_id"
          minSdkVersion 23
          targetSdkVersion 27
          versionCode 1
          versionName "1.0"
  
  
      }
  
      dataBinding {
          enabled = true
  
      }
  
      buildTypes {
         release {
             minifyEnabled false
             proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
         }
      }
  
      repositories {
          mavenCentral()
          google()
      }
  
      dataBinding {
          enabled = true
      }
  
  }
  
  dependencies {
      implementation project(':feature')
      implementation project(':base')
      implementation 'com.android.support:support-v4:27.0.2'
      implementation 'com.android.support:support-v13:27.0.2'
      implementation 'com.github.bumptech.glide:glide:4.5.0'
      implementation 'de.hdodenhof:circleimageview:2.2.0'
      annotationProcessor 'com.github.bumptech.glide:compiler:4.5.0'
  }
  </code></pre>
  
  <p>my build.gradle(Module:Base)</p>
  
  <pre><code>apply plugin: 'com.android.feature'
  
  apply plugin: 'kotlin-kapt'
  
  android {
      compileSdkVersion 27
      baseFeature true
      defaultConfig {
          minSdkVersion 23
          targetSdkVersion 27
          versionCode 1
          versionName "1.0"
      }
      buildTypes {
          release {
              minifyEnabled false
              proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
          }
      }
  
      dataBinding {
          enabled = true
      }
  
  }
  
  dependencies {
      api 'com.android.support:appcompat-v7:27.0.2'
      api 'com.android.support.constraint:constraint-layout:1.0.2'
      application project(':app')
      feature project(':feature')
  }
  </code></pre>
  
  <p>Build.gradle(Module: feature)</p>
  
  <pre><code>apply plugin: 'com.android.feature'
  
  apply plugin: 'kotlin-android'
  
  apply plugin: 'kotlin-android-extensions'
  
  apply plugin: 'kotlin-kapt'
  
  
  android {
      compileSdkVersion 27
      defaultConfig {
          minSdkVersion 23
          targetSdkVersion 27
          versionCode 1
          versionName "1.0"
          testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
      }
      buildTypes {
          release {
              minifyEnabled false
              proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
          }
      }
  
      repositories {
          google()
          jcenter()
          maven {
              url 'https://maven.google.com/'
          }
      }
  
  }
  
  dependencies {
      implementation fileTree(dir: 'libs', include: ['*.jar'])
      implementation "org.jetbrains.kotlin:kotlin-stdlib-jre7:$versions.kotlin_version"
      implementation "org.jetbrains.anko:anko:$versions.anko_version"
      implementation 'de.hdodenhof:circleimageview:2.2.0'
      implementation "com.github.bumptech.glide:glide:$versions.glide_version"
      kapt "com.github.bumptech.glide:compiler:$versions.glide_version"
      implementation project(':base')
      testImplementation 'junit:junit:4.12'
      androidTestImplementation 'com.android.support.test:runner:1.0.1'
      androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.1'
  
      kapt "com.android.databinding:compiler:$versions.android_plugin_version"
  }
  </code></pre>
  
  <p>and Build.Gradle(module:Instant app)</p>
  
  <pre><code>apply plugin: 'com.android.instantapp'
  
  dependencies {
      implementation project(':feature')
      implementation project(':base')
  }
  </code></pre>
  
  <p>Seems like the problem is because on databinding auto bind layout.</p>
  
  <p>I refered to <a href="https://stackoverflow.com/questions/33934249/android-databinding-package-does-not-exist">Android Databinding : package does not exist</a></p>
  
  <p>and <a href="https://stackoverflow.com/questions/46080018/kapt-not-generating-classes-in-instant-app-feature-module?rq=1">Kapt not generating classes in Instant app feature module</a></p>
  
  <p>Did I missed something on my build.gradles?</p>