title: Gradle build error in Android Studio for Dependent Spinner
body: <p>I was writing a code for my mobile app.</p>
  
  <p>My app is written in Kotlin instead of Java but if was say then I will Decompile in Java too.</p>
  
  <p>My main motive currently is to add a dependent list view option in my app using Spinner option and databinding. So I created some spinners in my activity_order.xml.</p>
  
  <p>This is my <strong>activity_order.xml</strong></p>
  
  <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt;
  &lt;androidx.constraintlayout.widget.ConstraintLayout 
  xmlns:android="http://schemas.android.com/apk/res/android"
      xmlns:app="http://schemas.android.com/apk/res-auto"
      xmlns:tools="http://schemas.android.com/tools"
      android:layout_width="match_parent"
      android:layout_height="match_parent"
      tools:context=".Order"&gt;
  
      &lt;ImageView
          android:id="@+id/imageView"
          android:layout_width="138dp"
          android:layout_height="96dp"
          android:layout_marginEnd="280dp"
          android:layout_marginRight="280dp"
          android:layout_marginBottom="632dp"
          app:layout_constraintBottom_toBottomOf="parent"
          app:layout_constraintEnd_toEndOf="parent"
          app:srcCompat="@drawable/logo_cut" /&gt;
  
      &lt;TextView
          android:id="@+id/textView2"
          android:layout_width="wrap_content"
          android:layout_height="wrap_content"
          android:layout_marginTop="136dp"
          android:text="DISTRICT NAME :"
          android:textColor="#000000"
          android:textSize="18sp"
          android:textStyle="bold"
          app:layout_constraintEnd_toEndOf="parent"
          app:layout_constraintHorizontal_bias="0.059"
          app:layout_constraintStart_toStartOf="parent"
          app:layout_constraintTop_toTopOf="parent" /&gt;
  
      &lt;TextView
          android:id="@+id/textView3"
          android:layout_width="wrap_content"
          android:layout_height="wrap_content"
          android:layout_marginTop="60dp"
          android:text="LIQUOR TYPE :"
          android:textColor="#000000"
          android:textSize="18sp"
          android:textStyle="bold"
          app:layout_constraintEnd_toEndOf="parent"
          app:layout_constraintHorizontal_bias="0.054"
          app:layout_constraintStart_toStartOf="parent"
          app:layout_constraintTop_toBottomOf="@+id/textView2" /&gt;
  
      &lt;TextView
          android:id="@+id/textView4"
          android:layout_width="wrap_content"
          android:layout_height="wrap_content"
          android:layout_marginTop="56dp"
          android:text="SHOP NAME :"
          android:textColor="#000000"
          android:textSize="18sp"
          android:textStyle="bold"
          app:layout_constraintEnd_toEndOf="parent"
          app:layout_constraintHorizontal_bias="0.053"
          app:layout_constraintStart_toStartOf="parent"
          app:layout_constraintTop_toBottomOf="@+id/textView3" /&gt;
  
      &lt;TextView
          android:id="@+id/textView5"
          android:layout_width="wrap_content"
          android:layout_height="wrap_content"
          android:layout_marginTop="60dp"
          android:text="LIQUOR BRAND :"
          android:textColor="#000000"
          android:textSize="18sp"
          android:textStyle="bold"
          app:layout_constraintEnd_toEndOf="parent"
          app:layout_constraintHorizontal_bias="0.058"
          app:layout_constraintStart_toStartOf="parent"
          app:layout_constraintTop_toBottomOf="@+id/textView4" /&gt;
  
      &lt;TextView
          android:id="@+id/textView6"
          android:layout_width="wrap_content"
          android:layout_height="wrap_content"
          android:text="QUANTITY :"
          android:textColor="#000000"
          android:textSize="18sp"
          android:textStyle="bold"
          app:layout_constraintBottom_toBottomOf="parent"
          app:layout_constraintEnd_toEndOf="parent"
          app:layout_constraintHorizontal_bias="0.05"
          app:layout_constraintStart_toStartOf="parent"
          app:layout_constraintTop_toBottomOf="@+id/textView5"
          app:layout_constraintVertical_bias="0.193" /&gt;
  
      &lt;Spinner
          android:id="@+id/spinner_district"
          android:layout_width="166dp"
          android:layout_height="26dp"
          android:layout_marginEnd="16dp"
          android:layout_marginRight="16dp"
          app:layout_constraintBottom_toBottomOf="parent"
          app:layout_constraintEnd_toEndOf="parent"
          app:layout_constraintStart_toEndOf="@+id/textView2"
          app:layout_constraintTop_toTopOf="parent"
          app:layout_constraintVertical_bias="0.192" /&gt;
  
      &lt;Spinner
          android:id="@+id/spinner_type"
          android:layout_width="166dp"
          android:layout_height="26dp"
          android:layout_marginEnd="16dp"
          android:layout_marginRight="16dp"
          app:layout_constraintBottom_toBottomOf="parent"
          app:layout_constraintEnd_toEndOf="parent"
          app:layout_constraintHorizontal_bias="0.623"
          app:layout_constraintStart_toEndOf="@+id/textView3"
          app:layout_constraintTop_toTopOf="parent"
          app:layout_constraintVertical_bias="0.309" /&gt;
  
      &lt;Spinner
          android:id="@+id/spinner_shop"
          android:layout_width="166dp"
          android:layout_height="26dp"
          android:layout_marginEnd="16dp"
          android:layout_marginRight="16dp"
          app:layout_constraintBottom_toBottomOf="parent"
          app:layout_constraintEnd_toEndOf="parent"
          app:layout_constraintHorizontal_bias="0.653"
          app:layout_constraintStart_toEndOf="@+id/textView4"
          app:layout_constraintTop_toTopOf="parent"
          app:layout_constraintVertical_bias="0.425" /&gt;
  
      &lt;Spinner
          android:id="@+id/spinner_brand"
          android:layout_width="166dp"
          android:layout_height="26dp"
          android:layout_marginEnd="16dp"
          android:layout_marginRight="16dp"
          app:layout_constraintBottom_toBottomOf="parent"
          app:layout_constraintEnd_toEndOf="parent"
          app:layout_constraintHorizontal_bias="0.545"
          app:layout_constraintStart_toEndOf="@+id/textView5"
          app:layout_constraintTop_toTopOf="parent"
          app:layout_constraintVertical_bias="0.541" /&gt;
  &lt;!--
      &lt;Spinner
          android:id="@+id/spinner_quantity"
          android:layout_width="166dp"
          android:layout_height="26dp"
          android:layout_marginEnd="16dp"
          android:layout_marginRight="16dp"
          app:layout_constraintBottom_toBottomOf="parent"
          app:layout_constraintEnd_toEndOf="parent"
          app:layout_constraintHorizontal_bias="0.698"
          app:layout_constraintStart_toEndOf="@+id/textView6"
          app:layout_constraintTop_toTopOf="parent"
          app:layout_constraintVertical_bias="0.66" /&gt;
      --&gt;
  
      &lt;Spinner
          android:id="@+id/spinner_quantity"
          android:layout_width="166dp"
          android:layout_height="26dp"
          android:layout_marginEnd="16dp"
          android:layout_marginRight="16dp"
          app:layout_constraintBottom_toBottomOf="parent"
          app:layout_constraintEnd_toEndOf="parent"
          app:layout_constraintHorizontal_bias="0.698"
          app:layout_constraintStart_toEndOf="@+id/textView6"
          app:layout_constraintTop_toTopOf="parent"
          app:layout_constraintVertical_bias="0.66" /&gt;
  
      &lt;Button
          android:id="@+id/btn1"
          android:layout_width="302dp"
          android:layout_height="34dp"
          android:layout_marginBottom="112dp"
          android:background="@drawable/custom_btn_proceed"
          android:text="PROCEED TO PAYMENT"
          android:textColor="#FFFFFF"
          android:textColorHint="#F44336"
          android:textSize="24sp"
          app:layout_constraintBottom_toBottomOf="parent"
          app:layout_constraintEnd_toEndOf="parent"
          app:layout_constraintHorizontal_bias="0.498"
          app:layout_constraintStart_toStartOf="parent"
          app:layout_constraintTop_toBottomOf="@+id/imageView3"
          app:layout_constraintVertical_bias="0.315" /&gt;
  
  &lt;/androidx.constraintlayout.widget.ConstraintLayout&gt;
  </code></pre>
  
  <p>In this activity I wanted to first create a dependent list with spinner id <strong><em>spinner_district</em></strong> and all the other are dependent to the upper spinner.</p>
  
  <p>So I first added the following code to my gradle file</p>
  
  <pre><code> viewBinding
               {
                   enabled=true
               }
  </code></pre>
  
  <p>and then started creating a Binding command for the list in my Kotlin file as follows</p>
  
  <pre><code> val binding = ActivityMainBinding.inflate(layoutInflater)
          setContentView(binding.root)
  
          val arrayList_District= arrayListOf&lt;String&gt;("Hapur","Meerut","Noida")
          val arrayAdapter_District=ArrayAdapter(applicationContext,R.layout.list_district,arrayList_District)
          binding.spParent.adapter=arrayAdapter_District
  </code></pre>
  
  <p>This is my full kotlin file for the activity_order.xml named as Order.kt</p>
  
  <pre><code>package com.example.e_dukan
  
  import android.app.Activity
  import androidx.appcompat.app.AppCompatActivity
  import android.os.Bundle
  import android.view.LayoutInflater
  import android.view.View
  import android.widget.AdapterView
  import android.widget.ArrayAdapter
  import android.widget.Spinner
  import com.example.e_dukan.databinding.ActivityMainBinding
  
  class Order : AppCompatActivity() {
  
      override fun onCreate(savedInstanceState: Bundle?) {
          super.onCreate(savedInstanceState)
          setContentView(R.layout.activity_order)
  
  ////////////////////////////////////////////////////////////////////////////////////////////////////
  ///////////////////////////// Binding Command for Dependent Spinner/////////////////////////////////
  ////////////////////////////////////////////////////////////////////////////////////////////////////
  
          val binding = ActivityMainBinding.inflate(layoutInflater)
          setContentView(binding.root)
  
          val arrayList_District= arrayListOf&lt;String&gt;("Hapur","Meerut","Noida")
          val arrayAdapter_District=ArrayAdapter(applicationContext,R.layout.list_district,arrayList_District)
          binding.spParent.adapter=arrayAdapter_District
  
  ////////////////////////////////////////////////////////////////////////////////////////////////////
  /////////////////////////// Spinner_district View Command///////////////////////////////////////////
  ////////////////////////////////////////////////////////////////////////////////////////////////////
  
          val spinner: Spinner = findViewById(R.id.spinner_district)
  // Create an ArrayAdapter using the string array and a default spinner layout
          ArrayAdapter.createFromResource(
              this,
              R.array.spinner_district,
              android.R.layout.simple_spinner_item
          ).also { adapter -&gt;
              // Specify the layout to use when the list of choices appears
              adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item)
              // Apply the adapter to the spinner
              spinner.adapter = adapter
          }
  
  ////////////////////////////////////////////////////////////////////////////////////////////////////
  
      }
  }
  /*
  class Order : Activity(), AdapterView.OnItemSelectedListener {
      override fun onItemSelected(parent: AdapterView&lt;*&gt;, view: View, pos: Int, id: Long) {
          // An item was selected. You can retrieve the selected item using
          // parent.getItemAtPosition(pos)
          val spinner: Spinner = findViewById(R.id.spinner_district)
          spinner.onItemSelectedListener = this
      }
  
      override fun onNothingSelected(parent: AdapterView&lt;*&gt;) {
          // Another interface callback
      }
  }
  */
  </code></pre>
  
  <p>But when ever i build the gradle it shows the following error</p>
  
  <pre><code>Executing tasks: [:app:assembleDebug] in project A:\E Dukan
  
  &gt; Task :app:preBuild UP-TO-DATE
  &gt; Task :app:preDebugBuild UP-TO-DATE
  &gt; Task :app:compileDebugRenderscript NO-SOURCE
  &gt; Task :app:compileDebugAidl NO-SOURCE
  &gt; Task :app:dataBindingMergeDependencyArtifactsDebug UP-TO-DATE
  &gt; Task :app:dataBindingMergeGenClassesDebug UP-TO-DATE
  &gt; Task :app:generateDebugResValues UP-TO-DATE
  &gt; Task :app:generateDebugResources UP-TO-DATE
  &gt; Task :app:generateDebugBuildConfig UP-TO-DATE
  &gt; Task :app:mainApkListPersistenceDebug UP-TO-DATE
  &gt; Task :app:createDebugCompatibleScreenManifests UP-TO-DATE
  &gt; Task :app:extractDeepLinksDebug UP-TO-DATE
  &gt; Task :app:processDebugManifest UP-TO-DATE
  &gt; Task :app:mergeDebugShaders UP-TO-DATE
  &gt; Task :app:compileDebugShaders UP-TO-DATE
  &gt; Task :app:generateDebugAssets UP-TO-DATE
  &gt; Task :app:mergeDebugAssets UP-TO-DATE
  &gt; Task :app:processDebugJavaRes NO-SOURCE
  &gt; Task :app:mergeDebugResources
  &gt; Task :app:dataBindingGenBaseClassesDebug
  &gt; Task :app:processDebugResources
  
  &gt; Task :app:compileDebugKotlin FAILED
  e: A:\E Dukan\app\src\main\java\com\example\e_dukan\Order.kt: (11, 40): Unresolved reference: ActivityMainBinding
  e: A:\E Dukan\app\src\main\java\com\example\e_dukan\Order.kt: (23, 23): Unresolved reference: ActivityMainBinding
  
  FAILURE: Build failed with an exception.
  
  * What went wrong:
  Execution failed for task ':app:compileDebugKotlin'.
  &gt; Compilation error. See log for more details
  
  * Try:
  Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.
  
  * Get more help at https://help.gradle.org
  
  BUILD FAILED in 9s
  15 actionable tasks: 4 executed, 11 up-to-date
  </code></pre>
  
  <p>Please help me solve this gradle build problem.</p>