title: What is the difference between the externalNativeBuild option inside/outside of the defaultConfig in android gradle file
body: <p>I saw that the build.gradle file automatically generated when I start a new ndk project has two <code>externalNativeBuild</code> options, one inside the <code>defaultConfig</code> option and one is parallel to the <code>defaultConfig</code> option. For instance, below are the content of the gradle file I have:
  apply plugin: 'com.android.application'</p>
  <pre><code>android {
      compileSdkVersion 30
      buildToolsVersion &quot;30.0.1&quot;
  
      defaultConfig {
          applicationId &quot;com.example.myapp&quot;
          minSdkVersion 21
          targetSdkVersion 30
          versionCode 1
          versionName &quot;1.0&quot;
  
          testInstrumentationRunner &quot;androidx.test.runner.AndroidJUnitRunner&quot;
          externalNativeBuild {
              cmake {
                  cppFlags &quot;&quot;
              }
          }
      }
  
      buildTypes {
          release {
              minifyEnabled false
              proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
          }
      }
      externalNativeBuild {
          cmake {
              path &quot;src/main/cpp/CMakeLists.txt&quot;
              version &quot;3.10.2&quot;
          }
      }
  }
  
  dependencies {
      implementation fileTree(dir: &quot;libs&quot;, include: [&quot;*.jar&quot;])
      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>
  <p>What are the differences between them? I searched the documentation and for the insider one it says:</p>
  <blockquote>
  <p>Encapsulates per-variant CMake and ndk-build configurations for your
  external native build.</p>
  </blockquote>
  <p>and for the outside one it says:</p>
  <blockquote>
  <p>DSL object to configure external native builds using CMake or
  ndk-build.</p>
  </blockquote>
  <p>but for the sub option of the outside one, e.g., the cmake option, it says:</p>
  <blockquote>
  <p>Encapsulates per-variant configurations for your external ndk-build
  project, such as the path to your CMakeLists.txt build script and
  build output directory.</p>
  </blockquote>
  <p>Now I am confused why there are two externalNativeBuild options, and how should I config each?</p>