title: How to prevent from C++ to recompile all files in Android NDK?
body: <p><strong>Hello,</strong></p>
  
  <p>I'm using the Android Studio with NDK and JNI in a project with a large amount of C++ files. When I make changes in a single C++ file
  <strong>it won't apply in the code unless I rebuild the whole project</strong> and refresh the entire
  C++ files so they have to recompile. The compilation process takes more than 3 minutes for every small change, make it 20 times a day and you have lost an hour.</p>
  
  <p>According to today, after I make a change to a file I go to</p>
  
  <p>Build >> Refresh Linked C++ Projects,</p>
  
  <p>and then run the project, resulting in a full, redundant compilation of all files. </p>
  
  <p><strong><em>I'm looking for way for the compiler to refresh only the changed file, and as a result shorten the build process.</em></strong></p>
  
  <p><strong>NOTE:</strong> This problem only occurs in windows, when I run Android Studio on a Mac, the compiler recompiles only the relevant files.  </p>
  
  <p>This is my CMakeLists.txt file:</p>
  
  <pre><code>cmake_minimum_required(VERSION 3.4.1)
  
  FILE(GLOB CPP_SRC
       "src/main/cpp/*.c"
       "src/main/cpp/*.h"
       "src/main/cpp/*.cpp"
       "src/main/cpp/*.hpp"
   )
  
  
  add_library(MyLib
  
               SHARED
               ${CPP_SRC} )
  
  find_library(
                log-lib
                log )
  
  target_link_libraries(
                         MyLib
  
                         ${log-lib} )
  
  target_link_libraries(MyLib
                        android
                        log
                        EGL
                        GLESv2)
  </code></pre>
  
  <p>And my gradle.build file:</p>
  
  <pre><code>apply plugin: 'com.android.library'
  
  android {
      signingConfigs {
          config {
              keyAlias '*****'
              keyPassword '*****'
              storeFile file(*****)
              storePassword '*****'
          }
      }
      compileSdkVersion 27
      buildToolsVersion '27.0.3'
      defaultConfig {
  
      minSdkVersion 16
      targetSdkVersion 27
      versionCode 1
  
      versionName "1.0"
      testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
  
      externalNativeBuild {
          cmake {
  
              arguments "-DANDROID_ARM_NEON=TRUE", "-DANDROID_TOOLCHAIN=clang", "-DANDROID_STL=c++_shared", "-DCMAKE_BUILD_TYPE=Release", "-DANDROID_CPP_FEATURES=rtti exceptions"
              cppFlags "-D__STDC_FORMAT_MACROS", '-Ofast', '-fsigned-char', "-std=c++14", "-frtti", "-fexceptions", "-mtune=arm7", "-mfpu=vfpv3-d16", "-mfloat-abi=softfp", "-Wall",
                      "-DCOMPILE_EUROPE_ID_AND_FACE_OCR_MANAGER",
                      "-DCOMPILE_FRENCH_PASSPORT_SIGNATURE",
                      "-DCOMPILE_FRENCH_ID_BACK_OCR",
                      "-DCOMPILE_FRENCH_PASSPORT_SIGNATURE_MANAGER",
                      "-DCOMPILE_PASSPORT_AND_FACE_OCR_MANAGER",
                      "-DCOMPILE_MRZ_OCR",
                      "-DCOMPILE_FRENCH_ID_BACK_OCR_MANAGER"
          }
  
          ndk {
              abiFilters 'x86', 'armeabi-v7a'
          }
      }
  
      splits {
          abi {
              enable true
              reset()
              include 'x86', 'armeabi-v7a'
              universalApk true
          }
      }
  }
      buildTypes {
         release {
              minifyEnabled false
              proguardFiles getDefaultProguardFile('proguard-android.txt'), 
             'proguard-rules.pro'
              signingConfig signingConfigs.config
      }
  }
      externalNativeBuild {
          cmake {
              path "CMakeLists.txt"
          }
      }
  
      libraryVariants.all { variant -&gt; variant.outputs.all { output -&gt; 
      outputFileName = "${"libScanovateImaging"}.aar" }
          }
      }
  
      allprojects {
              repositories {
              jcenter()
              maven {
                  url "https://maven.google.com"
              }
          }    
      }
      dependencies {
          implementation 'com.google.android.gms:play-services-vision:15.0.0'
          implementation 'com.android.support:recyclerview-v7:27.1.1'
          implementation fileTree(dir: 'libs', include: ['*.jar'])
          implementation 'com.android.support.constraint:constraint-layout:1.1.0-beta6'
          implementation 'com.android.support:appcompat-v7:27.1.1'
          implementation 'com.android.support:design:27.1.1'
  
  }
  </code></pre>
  
  <p><strong>Thanks in advance!</strong></p>