赞
踩
1.加载build.gradle文件里面通过
externalNativeBuild {
cmake {
path file('src/main/cpp/CMakeLists.txt')
version '3.18.1'
}
}
加载CMakeList.txt文件
报错
1.加载demo项目,grader编译使用的SDK不是合适当前APP版本,需要修改成29的版本,或者本地as下载对应的31的sdk,minSDK版本最小适应26
2.移植过来的demo,JNI无法加载,显示搜不到对应的JNI方法,SDK插件版本与NDK版本不一致,导致搜索不到对应的JNI方法
3.打开Project Structure 默认是没有NDK的,手动安装NDK确保编译正常
4.报错
[CXX1405] error when building with cmake using D:\gongzuo\demo\FASTDDSServer-master\app\src\main\cpp\CMakeLists.txt: Build command failed.
Error while executing process C:\Users\user\AppData\Local\Android\Sdk\cmake\3.18.1\bin\cmake.exe with arguments {-HD:\gongzuo\demo\FASTDDSServer-master\app\src\main\cpp -DCMAKE_SYSTEM_NAME=Android -DCMAKE_EXPORT_COMPILE_COMMANDS=ON -DCMAKE_SYSTEM_VERSION=26 -DANDROID_PLATFORM=android-26 -DANDROID_ABI=arm64-v8a -DCMAKE_ANDROID_ARCH_ABI=arm64-v8a -DANDROID_NDK=C:\Users\user\AppData\Local\Android\Sdk\ndk\21.4.7075529 -DCMAKE_ANDROID_NDK=C:\Users\user\AppData\Local\Android\Sdk\ndk\21.4.7075529 -DCMAKE_TOOLCHAIN_FILE=C:\Users\user\AppData\Local\Android\Sdk\ndk\21.4.7075529\build\cmake\android.toolchain.cmake -DCMAKE_MAKE_PROGRAM=C:\Users\user\AppData\Local\Android\Sdk\cmake\3.18.1\bin\ninja.exe -DCMAKE_CXX_FLAGS=-std=c++11 -DCMAKE_LIBRARY_OUTPUT_DIRECTORY=D:\gongzuo\demo\FASTDDSServer-master\app\build\intermediates\cxx\Debug\4t4fd482\obj\arm64-v8a -DCMAKE_RUNTIME_OUTPUT_DIRECTORY=D:\gongzuo\demo\FASTDDSServer-master\app\build\intermediates\cxx\Debug\4t4fd482\obj\arm64-v8a -DCMAKE_BUILD_TYPE=Debug -BD:\gongzuo\demo\FASTDDSServer-master\app.cxx\Debug\4t4fd482\arm64-v8a -GNinja}
存在CXX1405 这样的保存,且NDK可以使用但是无法生成os库,原因是因为DLL文件损坏导致,需要到网上去下载DLL库放置到C:\Windows\System32目录下,再执行 cmake成功
C:\Users\user\AppData\Local\Android\Sdk\cmake\3.18.1\bin>cmake.exe
Usage
cmake [options]
cmake [options]
cmake [options] -S -B
Specify a source directory to (re-)generate a build system for it in the
current working directory. Specify an existing build directory to
re-generate its build system.
Run 'cmake --help' for more information.
2.Cannot resolve corresponding JNI function Java_com_example_fastddsserver_MainActivity_ddsSayHellow. 无法解析对应的JNI函数
解决方案
1.去除勾选的Adroid NDK Support插件
2.检查NDK和SDK的版本
3.检查是否有阻止使用C++的插件
4.将Adroid NDK Support插件勾选回来,支持NDK
5.重启Android Studio
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。