为了账号安全,请及时绑定邮箱和手机立即绑定

CMake找不到JNI

CMake找不到JNI

慕姐4208626 2021-04-13 13:22:28
我创建了一个具有C ++支持的新Android Studio项目,但没有添加任何内容。该项目使用CMake构建,编译和运行。然后CMakeLists.txt,我在文件底部添加了以下两行代码,并收到CMake构建错误。find_package(Java COMPONENTS Development)       # Line 47find_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_LIBRARYSee 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 problemsCMake在从命令行调用时运行,但是由于某种原因在Android Studio中失败,我不确定为什么。
查看完整描述

3 回答

?
收到一只叮咚

TA贡献1821条经验 获得超4个赞

Could NOT find JNI (missing: JAVA_AWT_LIBRARY JAVA_JVM_LIBRARY

解决了


sudo apt-get install -y openjdk-8-jdk

sudo apt-get install -y default-jdk

export JAVA_HOME=/usr/lib/jvm/java-8-openjdk-amd64


查看完整回答
反对 回复 2021-04-28
  • 3 回答
  • 0 关注
  • 1291 浏览

添加回答

举报

0/150
提交
取消
意见反馈 帮助中心 APP下载
官方微信