当前位置: 首页 > news >正文

JNI初识

1.创建C/C++项目

https://developer.android.google.cn/studio/projects/add-native-code?authuser=0&hl=hu#new-project

2.配置cmake文件

https://developer.android.google.cn/studio/projects/configure-cmake?authuser=0&hl=hu

3.CMakeLists.txt文件详解

# For more information about using CMake with Android Studio, read the
# documentation: https://d.android.com/studio/projects/add-native-code.html.
# For more examples on how to use CMake, see https://github.com/android/ndk-samples.# Sets the minimum CMake version required for this project.
#[翻译]
#有关在Android Studio中使用CMake的更多信息,请阅读文档:https://d.android.com/studio/projects/add-native-code.html.
#有关如何使用CMake的更多示例,请参阅https://github.com/android/ndk-samples.#设置此项目所需的最低CMake版本。
cmake_minimum_required(VERSION 3.22.1)# Declares the project name. The project name can be accessed via ${ PROJECT_NAME},
# Since this is the top level CMakeLists.txt, the project name is also accessible
# with ${CMAKE_PROJECT_NAME} (both CMake variables are in-sync within the top level
# build script scope).
#[翻译]
#声明项目名称。
#项目名称可以通过${project_name}访问。由于这是顶级CMakeLists.txt,因此项目名称也可以
#通过${CMAKE_project_name}访问(这两个CMAKE变量在顶级构建脚本范围内是同步的)。
project("nativec")# 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.
#
# In this top level CMakeLists.txt, ${CMAKE_PROJECT_NAME} is used to define
# the target library name; in the sub-module's CMakeLists.txt, ${PROJECT_NAME}
# is preferred for the same purpose.
#
# In order to load a library into your app from Java/Kotlin, you must call
# System.loadLibrary() and pass the name of the library defined here;
# for GameActivity/NativeActivity derived applications, the same library name must be
# used in the AndroidManifest.xml file.
#[翻译]
#创建并命名一个库,将其设置为STATIC或SHARED,并提供其源代码的相对路径。
#您可以定义多个库,CMake会为您构建它们。
#Gradle会自动将共享库与APK打包在一起。
#在这个顶级CMakeLists.txt中,${CMAKE_PROJECT_NAME}用于定义目标库名称;
#在子模块的CMakeLists.txt中,出于同样的目的,${PROJECT_NAME}是首选。
#为了从Java/Kotlin将库加载到您的应用程序中,您必须调用System.loadLibrary()
#并传递此处定义的库的名称;对于GameActivity/NativeActivity派生的应用程序,
#AndroidManifest.xml文件中必须使用相同的库名称。
add_library(${CMAKE_PROJECT_NAME} SHARED# List C/C++ source files with relative paths to this CMakeLists.txt.native-lib.cpp)# Specifies libraries CMake should link to your target library. You
# can link libraries from various origins, such as libraries defined in this
# build script, prebuilt third-party libraries, or Android system libraries.
#[翻译]
#指定CMake应链接到目标库的库。您可以链接来自不同来源的库,例如此构建脚本中
#定义的库、预构建的第三方库或Android系统库。
target_link_libraries(${CMAKE_PROJECT_NAME}# List libraries link to the target libraryandroidlog)


文章转载自:

http://SHuRF0P2.thxfn.cn
http://1SMYQ4J6.thxfn.cn
http://GyLOHMXc.thxfn.cn
http://hxIu598X.thxfn.cn
http://1VZsZIBp.thxfn.cn
http://bJ2VAJ5G.thxfn.cn
http://ErbwaJ9Y.thxfn.cn
http://94UH6Xos.thxfn.cn
http://hPY2ZCzS.thxfn.cn
http://8HTHRENr.thxfn.cn
http://yioUG6s6.thxfn.cn
http://whouYgAd.thxfn.cn
http://8hsuEMOB.thxfn.cn
http://TpVtsvoS.thxfn.cn
http://AKePYolj.thxfn.cn
http://x3W9VRDN.thxfn.cn
http://FpP7Qoho.thxfn.cn
http://zBlOpRBs.thxfn.cn
http://s95xgYAI.thxfn.cn
http://kaE2Opqy.thxfn.cn
http://F8XaqBQa.thxfn.cn
http://dGXBoxNC.thxfn.cn
http://eke2jXjj.thxfn.cn
http://orgKLLrR.thxfn.cn
http://kFdv59jG.thxfn.cn
http://n4UzerlS.thxfn.cn
http://t0LsOsSp.thxfn.cn
http://Fh575Dg3.thxfn.cn
http://H7RGPgW5.thxfn.cn
http://1vIsEt7q.thxfn.cn
http://www.dtcms.com/a/376194.html

相关文章:

  • Linux 系统中高性能 I/O 事件通知机制的核心——`epoll_create` 系统调用
  • UNIX与Linux:五大核心差异解析
  • 大模型评测工程师学习清单与计划
  • 5.后台运行设置和包设计与实现
  • 深度学习入门:打好数学与机器学习基础,迈向AI进阶之路
  • 【AOSP 的分层设计理念与命名规范】
  • Docker 清理完整指南:释放磁盘空间的最佳实践
  • 进程状态(Linux)
  • Linux负载如何判断服务器的压力
  • 【网络编程】从与 TCP 服务器的对比中探讨出 UDP 协议服务器的并发方案(C 语言)
  • 第4讲 机器学习基础概念
  • 新加坡服务器连接速度变慢应该做哪些检查
  • Elasticsearch启动失败?5步修复权限问题
  • HR软件选型指南:SaaS还是本地部署好?
  • 基于51单片机简易计算器仿真设计(proteus仿真+程序+嘉立创原理图PCB+设计报告)
  • matlab基本操作和矩阵输入-台大郭彦甫视频
  • Power BI制作指标达成跟踪器
  • 邪修实战系列(3)
  • Mac m系列芯片向日葵打不开 解决方案
  • 【Unity Shader学习笔记】(七)顶点着色器
  • 宋红康 JVM 笔记 Day16|垃圾回收相关概念
  • 信号与系统
  • 第十四届蓝桥杯青少组C++选拔赛[2023.2.12]第二部分编程题(5、机甲战士)
  • NW597NW605美光固态闪存NW613NW614
  • C语言-指针用法概述
  • Jakarta EE课程 微型资料投递与分发 实验指导(付完整版代码)
  • 基于autoawq进行qwen3 的awq量化
  • ⸢ 肆 ⸥ ⤳ 默认安全建设方案:c-2.增量风险管控
  • Windows系统下KingbaseES数据库保姆级安装教程(附常见问题解决)
  • Python实现讯飞星火大模型Spark4.0Ultra的WebSocket交互详解