猿问

CMake找不到JNI

我创建了一个具有C ++支持的新Android Studio项目,但没有添加任何内容。该项目使用CMake构建,编译和运行。然后CMakeLists.txt,我在文件底部添加了以下两行代码,并收到CMake构建错误。


find_package(Java COMPONENTS Development)       # Line 47

find_package(JNI REQUIRED)                      # Line 48

这是我在构建项目时遇到的错误


-- 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

CMake在从命令行调用时运行,但是由于某种原因在Android Studio中失败,我不确定为什么。


慕姐4208626
浏览 1292回答 3
3回答

收到一只叮咚

Could NOT find JNI (missing: JAVA_AWT_LIBRARY JAVA_JVM_LIBRARY解决了sudo apt-get install -y openjdk-8-jdksudo apt-get install -y default-jdkexport JAVA_HOME=/usr/lib/jvm/java-8-openjdk-amd64
随时随地看视频慕课网APP

相关分类

Java
我要回答