title: Android in Kotlin: Error in Databinding from the project by Google codelabs
body: <p>I was doing this course offered by Google, <a href="https://codelabs.developers.google.com/codelabs/kotlin-android-training-data-binding-basics/index.html?index=..%2F..android-kotlin-fundamentals#2" rel="nofollow noreferrer">https://codelabs.developers.google.com/codelabs/kotlin-android-training-data-binding-basics/index.html?index=..%2F..android-kotlin-fundamentals#2</a>,</p>
  
  <p>The particular code in github: <a href="https://github.com/google-developer-training/android-kotlin-fundamentals-apps/tree/master/AboutMeDataBinding" rel="nofollow noreferrer">https://github.com/google-developer-training/android-kotlin-fundamentals-apps/tree/master/AboutMeDataBinding</a></p>
  
  <p>Here I was doing the data binding, which is shown step by step how to implement it. But at the end I was getting an error with 
  <code>ActivityMainBinding</code></p>
  
  <p>I have downloaded their solution code from github which on opening with Android-studio 3.4.1 , I got the same problem.</p>
  
  <p>In Main Acctivity.kt</p>
  
  <pre><code>  package com.example.android.aboutme
      import android.content.Context
       import android.os.Bundle
       import android.view.View
     import android.view.inputmethod.InputMethodManager
    import androidx.appcompat.app.AppCompatActivity 
     import androidx.databinding.DataBindingUtil
     import com.example.android.aboutme.databinding.ActivityMainBinding
  
   class MainActivity : AppCompatActivity() {
  
  private lateinit var binding: ActivityMainBinding
  
  private val myName: MyName = MyName("Aleks Haecky")
  
  override fun onCreate(savedInstanceState: Bundle?) {
      super.onCreate(savedInstanceState)
      binding = DataBindingUtil.setContentView(this, 
  R.layout.activity_main)
  
      binding.myName = myName
  
      binding.doneButton.setOnClickListener {
          addNickname(it)
      }
  
  }
  
  
   private fun addNickname(view: View) {
      binding. apply {
          myName?.nickname = nicknameEdit.text.toString()
          invalidateAll()
          nicknameEdit.visibility = View.GONE
          doneButton.visibility = View.GONE
          nicknameText.visibility = View.VISIBLE
      }
  
      // Hide the keyboard.
      val imm = getSystemService(Context.INPUT_METHOD_SERVICE) as InputMethodManager
      imm.hideSoftInputFromWindow(view.windowToken, 0)
  }
  }
  </code></pre>
  
  <p>Build.gradle(module:app)</p>
  
  <pre><code>apply plugin: 'com.android.application'
  
  apply plugin: 'kotlin-android'
  
  apply plugin: 'kotlin-android-extensions'
  
  android {
      compileSdkVersion 28
      defaultConfig {
          applicationId "com.example.android.aboutme"
          minSdkVersion 19
          targetSdkVersion 28
          versionCode 1
          versionName "1.0"
          testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
      }
      buildTypes {
          release {
              minifyEnabled false
              proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
          }
      }
      dataBinding {
          enabled = true
      }
  }
  
  dependencies {
      implementation fileTree(dir: 'libs', include: ['*.jar'])
      implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
      implementation 'androidx.appcompat:appcompat:1.0.2'
      testImplementation 'junit:junit:4.12'
  }
  </code></pre>
  
  <p>I expected to be all okay but ActivityMainBinding was red in colour. Error says unresolved reference.</p>
  
  <pre><code>IDE Fatal Error:
  java.lang.NullPointerException
      at com.intellij.build.MultipleBuildsView.lambda$onEvent$2(MultipleBuildsView.java:218)
      at com.intellij.build.MultipleBuildsView.lambda$onEvent$4(MultipleBuildsView.java:310)
      at com.intellij.openapi.application.impl.LaterInvocator$FlushQueue.doRun(LaterInvocator.java:435)
      at com.intellij.openapi.application.impl.LaterInvocator$FlushQueue.runNextEvent(LaterInvocator.java:419)
      at com.intellij.openapi.application.impl.LaterInvocator$FlushQueue.run(LaterInvocator.java:403)
      at java.awt.event.InvocationEvent.dispatch(InvocationEvent.java:311)
      at java.awt.EventQueue.dispatchEventImpl(EventQueue.java:762)
      at java.awt.EventQueue.access$500(EventQueue.java:98)
      at java.awt.EventQueue$3.run(EventQueue.java:715)
      at java.awt.EventQueue$3.run(EventQueue.java:709)
      at java.security.AccessController.doPrivileged(Native Method)
      at java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(ProtectionDomain.java:80)
      at java.awt.EventQueue.dispatchEvent(EventQueue.java:732)
      at com.intellij.ide.IdeEventQueue.defaultDispatchEvent(IdeEventQueue.java:755)
      at com.intellij.ide.IdeEventQueue._dispatchEvent(IdeEventQueue.java:704)
      at com.intellij.ide.IdeEventQueue.dispatchEvent(IdeEventQueue.java:391)
      at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:201)
      at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:116)
      at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:105)
      at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:101)
      at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:93)
      at java.awt.EventDispatchThread.run(EventDispatchThread.java:82)
  </code></pre>
  
  <pre><code>Unresolved reference: ActivityMainBinding
  Unresolved reference: ActivityMainBinding
  Unresolved reference: it
  Unresolved reference: nicknameEdit
  Unresolved reference: invalidateAll
  Unresolved reference: nicknameEdit
  Unresolved reference: doneButton
  Unresolved reference: nicknameText
  </code></pre>