title: error: package android.databinding does not exist
body: <p>I am building my first Android app. I am following this tutorial for making a calculator application by Android Authority here: <a href="https://www.androidauthority.com/build-a-calculator-app-721910" rel="nofollow noreferrer">https://www.androidauthority.com/build-a-calculator-app-721910</a></p>
  <p>I have the latest version of Android Studio installed and Gradle is up to date as well. I have been searching for a solution to this problem since days now. I have referred to many StackOverflow answers and have looked into my own code as well. I don't get any error using Sync Project with Gradle files. The error pops up only when I build the APK. Here is the error I am getting:</p>
  <pre><code>error: package android.databinding does not exist
  error: package android.support.v7.app does not exist
  error: package com.sample.foo.samplecalculator.databinding does not exist
  error: cannot find symbol AppCompactActivity
  cannot find symbol ActivityMainBinding
  </code></pre>
  <p>This is my MainActivity.java file:</p>
  <pre><code>package com.example.calculator;
  
  import android.databinding.DataBindingUtil;
  import android.support.v7.app.AppCompatActivity;
  import android.os.Bundle;
  import android.view.View;
  
  import com.sample.foo.samplecalculator.databinding.ActivityMainBinding;
  
  import java.text.DecimalFormat;
  
  public class MainActivity extends AppCompactActivity {
  
      private ActivityMainBinding binding;
  
      private static final char ADDITION = '+';
      private static final char SUBTRACTION = '-';
      private static final char MULTIPLICATION = '*';
      private static final char DIVISION = '/';
  
      private char CURRENT_ACTION;
  
      private double valueOne = Double.NaN;
      private double valueTwo;
  
      private DecimalFormat decimalFormat;
  
      @Override
      protected void onCreate(Bundle savedInstanceState) {
          super.onCreate(savedInstanceState);
  
          decimalFormat = new DecimalFormat(&quot;#.##########&quot;);
  
          binding = DataBindingUtil.setContentView(this, R.layout.activity_main);
  
          binding.buttonDot.setOnClickListener(new View.OnClickListener() {
              @Override
              public void onClick(View view) {
                  binding.editText.setText(binding.editText.getText() + &quot;.&quot;);
              }
          });
  
          binding.buttonZero.setOnClickListener(new View.OnClickListener() {
              @Override
              public void onClick(View view) {
                  binding.editText.setText(binding.editText.getText() + &quot;0&quot;);
              }
          });
  
          binding.buttonOne.setOnClickListener(new View.OnClickListener() {
              @Override
              public void onClick(View view) {
                  binding.editText.setText(binding.editText.getText() + &quot;1&quot;);
              }
          });
  
          binding.buttonTwo.setOnClickListener(new View.OnClickListener() {
              @Override
              public void onClick(View view) {
                  binding.editText.setText(binding.editText.getText() + &quot;2&quot;);
              }
          });
  
          binding.buttonThree.setOnClickListener(new View.OnClickListener() {
              @Override
              public void onClick(View view) {
                  binding.editText.setText(binding.editText.getText() + &quot;3&quot;);
              }
          });
  
          binding.buttonFour.setOnClickListener(new View.OnClickListener() {
              @Override
              public void onClick(View view) {
                  binding.editText.setText(binding.editText.getText() + &quot;4&quot;);
              }
          });
  
          binding.buttonFive.setOnClickListener(new View.OnClickListener() {
              @Override
              public void onClick(View view) {
                  binding.editText.setText(binding.editText.getText() + &quot;5&quot;);
              }
          });
  
          binding.buttonSix.setOnClickListener(new View.OnClickListener() {
              @Override
              public void onClick(View view) {
                  binding.editText.setText(binding.editText.getText() + &quot;6&quot;);
              }
          });
  
          binding.buttonSeven.setOnClickListener(new View.OnClickListener() {
              @Override
              public void onClick(View view) {
                  binding.editText.setText(binding.editText.getText() + &quot;7&quot;);
              }
          });
  
          binding.buttonEight.setOnClickListener(new View.OnClickListener() {
              @Override
              public void onClick(View view) {
                  binding.editText.setText(binding.editText.getText() + &quot;8&quot;);
              }
          });
  
          binding.buttonNine.setOnClickListener(new View.OnClickListener() {
              @Override
              public void onClick(View view) {
                  binding.editText.setText(binding.editText.getText() + &quot;9&quot;);
              }
          });
  
          binding.buttonAdd.setOnClickListener(new View.OnClickListener() {
              @Override
              public void onClick(View view) {
                  computeCalculation();
                  CURRENT_ACTION = ADDITION;
                  binding.infoTextView.setText(decimalFormat.format(valueOne) + &quot;+&quot;);
                  binding.editText.setText(null);
              }
          });
  
          binding.buttonSubtract.setOnClickListener(new View.OnClickListener() {
              @Override
              public void onClick(View view) {
                  computeCalculation();
                  CURRENT_ACTION = SUBTRACTION;
                  binding.infoTextView.setText(decimalFormat.format(valueOne) + &quot;-&quot;);
                  binding.editText.setText(null);
              }
          });
  
          binding.buttonMultiply.setOnClickListener(new View.OnClickListener() {
              @Override
              public void onClick(View view) {
                  computeCalculation();
                  CURRENT_ACTION = MULTIPLICATION;
                  binding.infoTextView.setText(decimalFormat.format(valueOne) + &quot;*&quot;);
                  binding.editText.setText(null);
              }
          });
  
          binding.buttonDivide.setOnClickListener(new View.OnClickListener() {
              @Override
              public void onClick(View view) {
                  computeCalculation();
                  CURRENT_ACTION = DIVISION;
                  binding.infoTextView.setText(decimalFormat.format(valueOne) + &quot;/&quot;);
                  binding.editText.setText(null);
              }
          });
  
          binding.buttonEqual.setOnClickListener(new View.OnClickListener() {
              @Override
              public void onClick(View view) {
                  computeCalculation();
                  binding.infoTextView.setText(binding.infoTextView.getText().toString() +
                          decimalFormat.format(valueTwo) + &quot; = &quot; + decimalFormat.format(valueOne));
                  valueOne = Double.NaN;
                  CURRENT_ACTION = '0';
              }
          });
  
          binding.buttonClear.setOnClickListener(new View.OnClickListener() {
              @Override
              public void onClick(View view) {
                  if(binding.editText.getText().length() &gt; 0) {
                      CharSequence currentText = binding.editText.getText();
                      binding.editText.setText(currentText.subSequence(0, currentText.length()-1));
                  }
                  else {
                      valueOne = Double.NaN;
                      valueTwo = Double.NaN;
                      binding.editText.setText(&quot;&quot;);
                      binding.infoTextView.setText(&quot;&quot;);
                  }
              }
          });
      }
  
      private void computeCalculation() {
          if(!Double.isNaN(valueOne)) {
              valueTwo = Double.parseDouble(binding.editText.getText().toString());
              binding.editText.setText(null);
  
              if(CURRENT_ACTION == ADDITION)
                  valueOne = this.valueOne + valueTwo;
              else if(CURRENT_ACTION == SUBTRACTION)
                  valueOne = this.valueOne - valueTwo;
              else if(CURRENT_ACTION == MULTIPLICATION)
                  valueOne = this.valueOne * valueTwo;
              else if(CURRENT_ACTION == DIVISION)
                  valueOne = this.valueOne / valueTwo;
          }
          else {
              try {
                  valueOne = Double.parseDouble(binding.editText.getText().toString());
              }
              catch (Exception e){}
          }
      }
  }
  </code></pre>
  <p>Here is the code to my activity_main.xml file:</p>
  <pre><code>&lt;?xml version=&quot;1.0&quot; encoding=&quot;utf-8&quot;?&gt;
  &lt;layout&gt;
  
      &lt;RelativeLayout xmlns:android=&quot;http://schemas.android.com/apk/res/android&quot;
          xmlns:tools=&quot;http://schemas.android.com/tools&quot;
          android:id=&quot;@+id/activity_main&quot;
          android:layout_width=&quot;match_parent&quot;
          android:layout_height=&quot;match_parent&quot;
          android:paddingBottom=&quot;@dimen/activity_vertical_margin&quot;
          android:paddingLeft=&quot;@dimen/activity_horizontal_margin&quot;
          android:paddingRight=&quot;@dimen/activity_horizontal_margin&quot;
          android:paddingTop=&quot;@dimen/activity_vertical_margin&quot;
          tools:context=&quot;.MainActivity&quot;&gt;
  
          &lt;TextView
              android:id=&quot;@+id/infoTextView&quot;
              android:layout_width=&quot;match_parent&quot;
              android:layout_height=&quot;wrap_content&quot;
              android:layout_marginBottom=&quot;30dp&quot;
              android:textSize=&quot;30sp&quot; /&gt;
  
          &lt;EditText
              android:id=&quot;@+id/editText&quot;
              android:layout_width=&quot;match_parent&quot;
              android:layout_height=&quot;wrap_content&quot;
              android:layout_below=&quot;@id/infoTextView&quot;
              android:enabled=&quot;false&quot;
              android:gravity=&quot;bottom&quot;
              android:lines=&quot;2&quot;
              android:maxLines=&quot;2&quot;
              android:textSize=&quot;20sp&quot; /&gt;
  
          &lt;Button
              android:id=&quot;@+id/buttonSeven&quot;
              style=&quot;@style/Widget.AppCompat.Button.Borderless&quot;
              android:layout_width=&quot;wrap_content&quot;
              android:layout_height=&quot;wrap_content&quot;
              android:layout_below=&quot;@id/editText&quot;
              android:text=&quot;7&quot;
              android:textSize=&quot;20sp&quot; /&gt;
  
          &lt;Button
              android:id=&quot;@+id/buttonEight&quot;
              style=&quot;@style/Widget.AppCompat.Button.Borderless&quot;
              android:layout_width=&quot;wrap_content&quot;
              android:layout_height=&quot;wrap_content&quot;
              android:layout_below=&quot;@id/editText&quot;
              android:layout_toRightOf=&quot;@id/buttonSeven&quot;
              android:text=&quot;8&quot;
              android:textSize=&quot;20sp&quot; /&gt;
  
          &lt;Button
              android:id=&quot;@+id/buttonNine&quot;
              style=&quot;@style/Widget.AppCompat.Button.Borderless&quot;
              android:layout_width=&quot;wrap_content&quot;
              android:layout_height=&quot;wrap_content&quot;
              android:layout_below=&quot;@id/editText&quot;
              android:layout_toRightOf=&quot;@id/buttonEight&quot;
              android:text=&quot;9&quot;
              android:textSize=&quot;20sp&quot; /&gt;
  
          &lt;Button
              android:id=&quot;@+id/buttonFour&quot;
              style=&quot;@style/Widget.AppCompat.Button.Borderless&quot;
              android:layout_width=&quot;wrap_content&quot;
              android:layout_height=&quot;wrap_content&quot;
              android:layout_below=&quot;@id/buttonSeven&quot;
              android:text=&quot;4&quot;
              android:textSize=&quot;20sp&quot; /&gt;
  
          &lt;Button
              android:id=&quot;@+id/buttonFive&quot;
              style=&quot;@style/Widget.AppCompat.Button.Borderless&quot;
              android:layout_width=&quot;wrap_content&quot;
              android:layout_height=&quot;wrap_content&quot;
              android:layout_alignRight=&quot;@id/buttonEight&quot;
              android:layout_below=&quot;@id/buttonEight&quot;
              android:text=&quot;5&quot;
              android:textSize=&quot;20sp&quot; /&gt;
  
          &lt;Button
              android:id=&quot;@+id/buttonSix&quot;
              style=&quot;@style/Widget.AppCompat.Button.Borderless&quot;
              android:layout_width=&quot;wrap_content&quot;
              android:layout_height=&quot;wrap_content&quot;
              android:layout_alignRight=&quot;@id/buttonNine&quot;
              android:layout_below=&quot;@id/buttonNine&quot;
              android:text=&quot;6&quot;
              android:textSize=&quot;20sp&quot; /&gt;
  
          &lt;Button
              android:id=&quot;@+id/buttonOne&quot;
              style=&quot;@style/Widget.AppCompat.Button.Borderless&quot;
              android:layout_width=&quot;wrap_content&quot;
              android:layout_height=&quot;wrap_content&quot;
              android:layout_below=&quot;@id/buttonFour&quot;
              android:text=&quot;1&quot;
              android:textSize=&quot;20sp&quot; /&gt;
  
          &lt;Button
              android:id=&quot;@+id/buttonTwo&quot;
              style=&quot;@style/Widget.AppCompat.Button.Borderless&quot;
              android:layout_width=&quot;wrap_content&quot;
              android:layout_height=&quot;wrap_content&quot;
              android:layout_alignRight=&quot;@id/buttonEight&quot;
              android:layout_below=&quot;@id/buttonFive&quot;
              android:text=&quot;2&quot;
              android:textSize=&quot;20sp&quot; /&gt;
  
          &lt;Button
              android:id=&quot;@+id/buttonThree&quot;
              style=&quot;@style/Widget.AppCompat.Button.Borderless&quot;
              android:layout_width=&quot;wrap_content&quot;
              android:layout_height=&quot;wrap_content&quot;
              android:layout_alignRight=&quot;@id/buttonNine&quot;
              android:layout_below=&quot;@id/buttonSix&quot;
              android:text=&quot;3&quot;
              android:textSize=&quot;20sp&quot; /&gt;
  
          &lt;Button
              android:id=&quot;@+id/buttonDot&quot;
              style=&quot;@style/Widget.AppCompat.Button.Borderless&quot;
              android:layout_width=&quot;wrap_content&quot;
              android:layout_height=&quot;wrap_content&quot;
              android:layout_below=&quot;@id/buttonOne&quot;
              android:text=&quot;.&quot;
              android:textSize=&quot;20sp&quot; /&gt;
  
          &lt;Button
              android:id=&quot;@+id/buttonZero&quot;
              style=&quot;@style/Widget.AppCompat.Button.Borderless&quot;
              android:layout_width=&quot;wrap_content&quot;
              android:layout_height=&quot;wrap_content&quot;
              android:layout_alignRight=&quot;@id/buttonEight&quot;
              android:layout_below=&quot;@id/buttonTwo&quot;
              android:text=&quot;0&quot;
              android:textSize=&quot;20sp&quot; /&gt;
  
          &lt;Button
              android:id=&quot;@+id/buttonEqual&quot;
              style=&quot;@style/Widget.AppCompat.Button.Borderless&quot;
              android:layout_width=&quot;wrap_content&quot;
              android:layout_height=&quot;wrap_content&quot;
              android:layout_alignRight=&quot;@id/buttonNine&quot;
              android:layout_below=&quot;@id/buttonThree&quot;
              android:text=&quot;=&quot;
              android:textSize=&quot;20sp&quot; /&gt;
  
          &lt;Button
              android:id=&quot;@+id/buttonDivide&quot;
              style=&quot;@style/Widget.AppCompat.Button.Borderless&quot;
              android:layout_width=&quot;wrap_content&quot;
              android:layout_height=&quot;wrap_content&quot;
              android:layout_alignTop=&quot;@id/buttonNine&quot;
              android:layout_toRightOf=&quot;@id/buttonNine&quot;
              android:text=&quot;/&quot;
              android:textSize=&quot;20sp&quot; /&gt;
  
          &lt;Button
              android:id=&quot;@+id/buttonMultiply&quot;
              style=&quot;@style/Widget.AppCompat.Button.Borderless&quot;
              android:layout_width=&quot;wrap_content&quot;
              android:layout_height=&quot;wrap_content&quot;
              android:layout_alignTop=&quot;@id/buttonSix&quot;
              android:layout_toRightOf=&quot;@id/buttonSix&quot;
              android:text=&quot;*&quot;
              android:textSize=&quot;20sp&quot; /&gt;
  
          &lt;Button
              android:id=&quot;@+id/buttonSubtract&quot;
              style=&quot;@style/Widget.AppCompat.Button.Borderless&quot;
              android:layout_width=&quot;wrap_content&quot;
              android:layout_height=&quot;wrap_content&quot;
              android:layout_alignTop=&quot;@id/buttonThree&quot;
              android:layout_toRightOf=&quot;@id/buttonThree&quot;
              android:text=&quot;-&quot;
              android:textSize=&quot;20sp&quot; /&gt;
  
          &lt;Button
              android:id=&quot;@+id/buttonAdd&quot;
              style=&quot;@style/Widget.AppCompat.Button.Borderless&quot;
              android:layout_width=&quot;wrap_content&quot;
              android:layout_height=&quot;wrap_content&quot;
              android:layout_alignTop=&quot;@id/buttonEqual&quot;
              android:layout_toRightOf=&quot;@id/buttonEqual&quot;
              android:text=&quot;+&quot;
              android:textSize=&quot;20sp&quot; /&gt;
  
          &lt;Button
              android:id=&quot;@+id/buttonClear&quot;
              style=&quot;@style/Widget.AppCompat.Button.Borderless&quot;
              android:layout_width=&quot;wrap_content&quot;
              android:layout_height=&quot;wrap_content&quot;
              android:layout_alignRight=&quot;@id/buttonAdd&quot;
              android:layout_below=&quot;@id/buttonAdd&quot;
              android:layout_marginTop=&quot;@dimen/activity_vertical_margin&quot;
              android:text=&quot;C&quot;
              android:textSize=&quot;20sp&quot; /&gt;
      &lt;/RelativeLayout&gt;
  &lt;/layout&gt;
  </code></pre>
  <p>The build.gradle(app) is as follows:</p>
  <pre><code>    apply plugin: 'com.android.application'
  
  android {
      compileSdkVersion 29
      buildToolsVersion &quot;29.0.3&quot;
      dataBinding.enabled = true
  
      defaultConfig {
          applicationId &quot;com.example.calculator&quot;
          minSdkVersion 16
          targetSdkVersion 29
          versionCode 1
          versionName &quot;1.0&quot;
  
          testInstrumentationRunner &quot;androidx.test.runner.AndroidJUnitRunner&quot;
      }
  
      buildTypes {
          release {
              minifyEnabled false
              proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
          }
      }
  
  }
  
  dependencies {
      implementation fileTree(dir: 'libs', include: ['*.jar'])
  
      implementation 'androidx.appcompat:appcompat:1.1.0'
      implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
      testImplementation 'junit:junit:4.12'
      androidTestImplementation 'androidx.test.ext:junit:1.1.1'
      androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0'
  }
  </code></pre>