title: CMake could not find JNI
body: <p>I created a new Android Studio Project with C++ support and did not add anything to it. The project builds, compiles and runs with CMake. I then added the following two lines of code to <code>CMakeLists.txt</code> at the bottom of the file and I get a CMake build error.</p>
  
  <pre><code>find_package(Java COMPONENTS Development)       # Line 47
  find_package(JNI REQUIRED)                      # Line 48
  </code></pre>
  
  <p>And this is the error I get when building the project</p>
  
  <pre><code>-- Found Java: /usr/lib/jvm/java-10-oracle/bin/java (found version "10.0.1") found components:  Development 
  -- Configuring incomplete, errors occurred!
  CMake Error at /home/xxxxx/Android/Sdk/cmake/3.6.4111459/share/cmake-3.6/Modules/FindPackageHandleStandardArgs.cmake:148 (message):
    Could NOT find JNI (missing: JAVA_AWT_LIBRARY JAVA_JVM_LIBRARY
  See also "/home/xxxxx/AndroidStudioProjects/MyApplication/app/.externalNativeBuild/cmake/release/x86_64/CMakeFiles/CMakeOutput.log".
    JAVA_INCLUDE_PATH2 JAVA_AWT_INCLUDE_PATH)
  Call Stack (most recent call first):
    /home/xxxxxx/Android/Sdk/cmake/3.6.4111459/share/cmake-3.6/Modules/FindPackageHandleStandardArgs.cmake:388 (_FPHSA_FAILURE_MESSAGE)
    /home/xxxxxx/Android/Sdk/cmake/3.6.4111459/share/cmake-3.6/Modules/FindJNI.cmake:314 (FIND_PACKAGE_HANDLE_STANDARD_ARGS)
    CMakeLists.txt:48 (find_package)
  External native generate JSON release: JSON generation completed with problems
  </code></pre>
  
  <p>CMake runs when being called form the command line, but fails inside Android Studio for some reason and I am not sure why. </p>
  
  <p><strong>EDIT 1</strong></p>
  
  <p>Here is the <a href="https://pastebin.com/vZXfkPya" rel="noreferrer">CMakeOutput.log</a> file </p>
  
  <p><strong>EDIT 2</strong></p>
  
  <p>This is all that is in <code>CMakeLists.txt</code> file. It compiles in cmd with the command cmake.</p>
  
  <pre><code>cmake_minimum_required(VERSION 3.4.1)
  
  find_package(Java COMPONENTS Development)
  find_package(JNI REQUIRED)
  </code></pre>
  
  <p>This is the cmd output</p>
  
  <pre><code>    E:\Users\xxxxx\AndroidStudioProjects\MyApplication\app\build&gt;cmake ..
  -- Configuring done
  -- Generating done
  -- Build files have been written to: E:/Users/xxxxx/AndroidStudioProjects/MyApplication/app/build
  </code></pre>
  
  <p>When I try to add it compile it in Android Studio using gradle I get the following error on Windows 10 pro 64 bit</p>
  
  <pre><code>Microsoft Windows [Version 10.0.17134.112]
  (c) 2018 Microsoft Corporation. All rights reserved.
  
  E:\Users\xxxxx\AndroidStudioProjects\MyApplication&gt;gradlew build --stacktrace
  
  &gt; Task :app:generateJsonModelDebug 
  External native generate JSON debug: starting JSON generation
  External native generate JSON debug: using platform version 24 for ABI ARMEABI_V7A and min SDK version 24
  External native generate JSON debug: noticing that build file 'E:\Users\xxxxx\AndroidStudioProjects\MyApplication\app\CMakeLists.txt' is out of date with respect to E:\Users\xxxxx\AndroidStudioProjects\MyApplication\app\.extern
  alNativeBuild\cmake\debug\armeabi-v7a\android_gradle_build.json
  External native generate JSON debug: rebuilding JSON E:\Users\xxxxx\AndroidStudioProjects\MyApplication\app\.externalNativeBuild\cmake\debug\armeabi-v7a\android_gradle_build.json due to:
  External native generate JSON debug: - a dependent build file changed
  External native generate JSON debug: keeping json folder 'E:\Users\xxxxx\AndroidStudioProjects\MyApplication\app\.externalNativeBuild\cmake\debug\armeabi-v7a' but regenerating project
  External native generate JSON debug: executing cmake Executable : E:\Android\SDK\cmake\3.6.4111459\bin\cmake.exe
  arguments :
  -HE:\Users\xxxxx\AndroidStudioProjects\MyApplication\app
  -BE:\Users\xxxxx\AndroidStudioProjects\MyApplication\app\.externalNativeBuild\cmake\debug\armeabi-v7a
  -DANDROID_ABI=armeabi-v7a
  -DANDROID_PLATFORM=android-24
  -DCMAKE_LIBRARY_OUTPUT_DIRECTORY=E:\Users\xxxxx\AndroidStudioProjects\MyApplication\app\build\intermediates\cmake\debug\obj\armeabi-v7a
  -DCMAKE_BUILD_TYPE=Debug
  -DANDROID_NDK=E:\Android\SDK\ndk-bundle
  -DCMAKE_CXX_FLAGS=
  -DCMAKE_TOOLCHAIN_FILE=E:\Android\SDK\ndk-bundle\build\cmake\android.toolchain.cmake
  -DCMAKE_MAKE_PROGRAM=E:\Android\SDK\cmake\3.6.4111459\bin\ninja.exe
  -GAndroid Gradle - Ninja
  jvmArgs :
  
  
  CMake Error at E:/Android/SDK/cmake/3.6.4111459/share/cmake-3.6/Modules/FindPackageHandleStandardArgs.cmake:148 (message):
    Could NOT find JNI (missing: JAVA_AWT_LIBRARY JAVA_JVM_LIBRARY
    JAVA_INCLUDE_PATH2 JAVA_AWT_INCLUDE_PATH)
  Call Stack (most recent call first):
    E:/Android/SDK/cmake/3.6.4111459/share/cmake-3.6/Modules/FindPackageHandleStandardArgs.cmake:388 (_FPHSA_FAILURE_MESSAGE)
    E:/Android/SDK/cmake/3.6.4111459/share/cmake-3.6/Modules/FindJNI.cmake:314 (FIND_PACKAGE_HANDLE_STANDARD_ARGS)
    CMakeLists.txt:4 (find_package)
  -- Configuring incomplete, errors occurred!
  See also "E:/Users/xxxxx/AndroidStudioProjects/MyApplication/app/.externalNativeBuild/cmake/debug/armeabi-v7a/CMakeFiles/CMakeOutput.log".
  </code></pre>