title: app\src\main\cpp\CMakeLists.txt : C/C++ debug|arm64-v8a : Configuration failed
body: <p>I copied the necessary .so files under the <code>jnilibs</code> folder, and configured the below files in an android ndk project using jni interface. While running the project, it throws an error as seen below.</p>
  <p>build.gradle</p>
  <pre><code>defaultConfig{
          testInstrumentationRunner &quot;androidx.test.runner.AndroidJUnitRunner&quot;
          externalNativeBuild {
              cmake {
                  cppFlags &quot;-frtti -fexceptions&quot;
                  abiFilters 'arm64-v8a'
              }
          }
      }
  
      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;
          }
      }
  </code></pre>
  <p>This my CMakeLists.txt</p>
  <pre><code># For more information about using CMake with Android Studio, read the
  # documentation: https://d.android.com/studio/projects/add-native-code.html
  cmake_minimum_required(VERSION 3.4.1)
  # Sets the minimum version of CMake required to build the native library.
  #Import header file
  include_directories(src/main/jniLibs/include)
  
  #Declare the import file to change the directory variable ARM_DIR, which uses the relative directory with the system, because using the relative path does not seem to work
  set(ARM_DIR C:/Users/Username/AndroidStudioProjectsFolder/ExamplAppName/app/src/main/jniLibs)
  
  #Add an example of so library.
  add_library(avdevice
          SHARED
          IMPORTED)
  set_target_properties(avdevice
          PROPERTIES IMPORTED_LOCATION
          ${ARM_DIR}/arm64-v8a/libavdevice.so)
  
  #Adding other so libraries in the same format as above
  #Link library
  target_link_libraries(
          native-lib
          avdevice
          avformat
          ${log-lib} )
  
  # Creates and names a library, sets it as either STATIC
  # or SHARED, and provides the relative paths to its source code.
  # You can define multiple libraries, and CMake builds them for you.
  # Gradle automatically packages shared libraries with your APK.
  
  #add_library( # Sets the name of the library.
  #             native-lib
  #
  #             # Sets the library as a shared library.
  #             SHARED
  #
  #             # Provides a relative path to your source file(s).
  #             native-lib.cpp )
  #
  ## Searches for a specified prebuilt library and stores the path as a
  ## variable. Because CMake includes system libraries in the search path by
  ## default, you only need to specify the name of the public NDK library
  ## you want to add. CMake verifies that the library exists before
  ## completing its build.
  #
  #find_library( # Sets the name of the path variable.
  #              log-lib
  #
  #              # Specifies the name of the NDK library that
  #              # you want CMake to locate.
  #              log )
  #
  ## Specifies libraries CMake should link to your target library. You
  ## can link multiple libraries, such as libraries you define in this
  ## build script, prebuilt third-party libraries, or system libraries.
  #
  #target_link_libraries( # Specifies the target library.
  #                       native-lib
  #
  #                       # Links the target library to the log library
  #                       # included in the NDK.
  #                       ${log-lib} )
  </code></pre>
  <p>Its native-lib.cpp file under the <code>cpp/</code> directory:</p>
  <pre><code>#include &lt;jni.h&gt;
  #include &lt;string&gt;
  
  extern &quot;C&quot;
  {
  #include &quot;libavformat/avformat.h&quot;
  }
  
  extern &quot;C&quot; JNIEXPORT jstring JNICALL
  Java_com_examples_examplappname_MainActivity_stringFromJNI(
          JNIEnv* env,
          jobject /* this */) {
      std::string hello = &quot;Hello from C++&quot;;
      av_register_all();
      return env-&gt;NewStringUTF(hello.c_str());
  }
  </code></pre>
  <p><code>.java</code> source code:</p>
  <pre><code>static {
              System.loadLibrary(&quot;avdevice&quot;);
              System.loadLibrary(&quot;avformat&quot;);
              System.loadLibrary(&quot;native-lib&quot;);
          }
  
      TextView tv = findViewById(R.id.sample_text);
      tv.setText(stringFromJNI());
  </code></pre>
  <p>Error:</p>
  <pre><code>**Starting Gradle Daemon...
  Gradle Daemon started in 4 s 270 ms
  KotlinDslScriptsParameter(correlationId=22803889351800, scriptFiles=[]) =&gt; StandardKotlinDslScriptsModel(scripts=[], commonModel=CommonKotlinDslScriptModel(classPath=[], sourcePath=[], implicitImports=[]), dehydratedScriptModels={}) - took 0.128 secs
  
  app\src\main\cpp\CMakeLists.txt : C/C++ debug|arm64-v8a : Configuration failed.
  app\src\main\cpp\CMakeLists.txt : C/C++ debug|arm64-v8a : CMake Error at app\src\main\cpp\CMakeLists.txt:21 (target_link_libraries):
    Cannot specify link libraries for target &quot;native-lib&quot; which is not built by
    this project
  
  app\src\main\cpp\CMakeLists.txt : C/C++ debug|arm64-v8a : Configuration failed.
  executing external native build for cmake 
  app\src\main\cpp\CMakeLists.txt
  
  CONFIGURE SUCCESSFUL in 3m 33s**
  </code></pre>