title: Import BuildConfig in Android Studio using Gradle
body: <p>I am new to Android Studio and I am trying to get <code>versionCode</code> in <code>build.gradle</code>.</p>
  
  <p>I have read <a href="https://stackoverflow.com/questions/60584946/buildconfig-is-not-working-in-android-studio-3-6-1">this post</a> and <a href="https://stackoverflow.com/questions/4616095/how-to-get-the-build-version-number-of-your-android-application">this post</a>, and I tried their solution:</p>
  
  <pre><code>import com.example.BuildConfig;
  ...
  ...
  ...
  // Get current version code
  int currentVersionCode = BuildConfig.VERSION_CODE;
  </code></pre>
  
  <p>But IDE keeps saying <code>Cannot resolve symbol 'BuildConfig'</code>. Actually I haven't found any string in the whole project folder named "BuildConfig" (searched in  Windows Explorer). Is there something wrong with my project configuration/creation?</p>
  
  <hr>
  
  <p><code>defaultConfig</code> in <code>build.gradle (module: app)</code> is like</p>
  
  <pre><code>    defaultConfig {
          applicationId "com.foo.bar"
          minSdkVersion 16
          targetSdkVersion 29
          versionCode 1
          versionName "1.0"
  
          testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
      }
  </code></pre>