欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页

NDK使用遇到的那些事(持续更新当中)

程序员文章站 2022-06-06 17:50:04
...

:AppCamera:transformNativeLibsWithStripDebugSymbolForDebug

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':AppCamera:transformNativeLibsWithStripDebugSymbolForDebug'.
> A problem occurred starting process 'command 'D:\devTools\AndroidSDK\ndk-bundle\toolchains\mips64el-linux-android-4.9\prebuilt\windows-x86_64\bin\mips64el-linux-android-strip''

* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.

原因是升级NDK(android-ndk-r17-windows-x86_64)最新版本之后找不到ndk-bundle\toolchains\mips64el-linux-android-4.9\prebuilt\windows-x86_64\bin\mips64el-linux-android-导致的,删除升级之后的NDK版本,如果是通过AS中升级的最好在AS中删除,然后在下载旧版本的NDK,以下是android-ndk-r16b下载地址:

https://dl.google.com/android/repository/android-ndk-r16b-windows-x86.zip
https://dl.google.com/android/repository/android-ndk-r16b-windows-x86_64.zip
https://dl.google.com/android/repository/android-ndk-r16b-darwin-x86_64.zip
https://dl.google.com/android/repository/android-ndk-r16b-linux-x86_64.zip

下载完成解压到之前的目录即可,运行即可,如果此时运行还报错,请继续往下读

CMake Error in CMakeLists.txt:The CMAKE_CXX_COMPILER:ndk-bundle/toolchains/llvm/prebuilt/windows-x86_64/bin/clang++.exe is not a full path to an existing compiler tool

-- Build files have been written to: F:/workplace/duanbinbin/pano-share-sdk-android/PanoShareSDKAndroid/DemoJNI/.externalNativeBuild/cmake/debug/armeabi-v7a
[1/3] Building CXX object CMakeFiles/link
.dir/JNIHelper.cpp.o
[2/3] Building CXX object CMakeFiles/link.dir/link.cpp.o
FAILED: D:\devTools\AndroidSDK\ndk-bundle\toolchains\llvm\prebuilt\windows\bin\clang++.exe  --target=armv7-none-linux-androideabi --gcc-toolchain=D:/devTools/AndroidSDK/ndk-bundle/toolchains/arm-linux-androideabi-4.9/prebuilt/windows-x86_64 --sysroot=D:/devTools/AndroidSDK/ndk-bundle/sysroot  -Dlink_EXPORTS -IF:/workplace/duanbinbin/pano-share-sdk-android/PanoShareSDKAndroid/DemoJNI/src/main/cpp/include -isystem D:/devTools/AndroidSDK/ndk-bundle/sources/cxx-stl/gnu-libstdc++/4.9/include -isystem D:/devTools/AndroidSDK/ndk-bundle/sources/cxx-stl/gnu-libstdc++/4.9/libs/armeabi-v7a/include -isystem D:/devTools/AndroidSDK/ndk-bundle/sources/cxx-stl/gnu-libstdc++/4.9/include/backward -isystem D:/devTools/AndroidSDK/ndk-bundle/sysroot/usr/include/arm-linux-androideabi -D__ANDROID_API__=24 -g -DANDROID -ffunction-sections -funwind-tables -fstack-protector-strong -no-canonical-prefixes -march=armv7-a -mfloat-abi=softfp -mfpu=vfpv3-d16 -fno-integrated-as -mthumb -Wa,--noexecstack -Wformat -Werror=format-security   -std=gnu++11 -O0 -fno-limit-debug-info  -fPIC -MD -MT CMakeFiles/link.dir/JNIHelper.cpp.o -MF CMakeFiles\link.dir\JNIHelper.cpp.o.d -o CMakeFiles/link.dir/JNIHelper.cpp.o -c F:\workplace\duanbinbin\pano-share-sdk-android\PanoShareSDKAndroid\DemoJNI\src\main\cpp\JNIHelper.cpp
clang++.exe: error: unable to execute command: program not executable
clang++.exe: error: assembler command failed with exit code 1 (use -v to see invocation)
FAILED: D:\devTools\AndroidSDK\ndk-bundle\toolchains\llvm\prebuilt\windows\bin\clang++.exe  --target=armv7-none-linux-androideabi --gcc-toolchain=D:/devTools/AndroidSDK/ndk-bundle/toolchains/arm-linux-androideabi-4.9/prebuilt/windows-x86_64 --sysroot=D:/devTools/AndroidSDK/ndk-bundle/sysroot  -Dlink_EXPORTS -IF:/workplace/duanbinbin/pano-share-sdk-android/PanoShareSDKAndroid/DemoJNI/src/main/cpp/include -isystem D:/devTools/AndroidSDK/ndk-bundle/sources/cxx-stl/gnu-libstdc++/4.9/include -isystem D:/devTools/AndroidSDK/ndk-bundle/sources/cxx-stl/gnu-libstdc++/4.9/libs/armeabi-v7a/include -isystem D:/devTools/AndroidSDK/ndk-bundle/sources/cxx-stl/gnu-libstdc++/4.9/include/backward -isystem D:/devTools/AndroidSDK/ndk-bundle/sysroot/usr/include/arm-linux-androideabi -D__ANDROID_API__=24 -g -DANDROID -ffunction-sections -funwind-tables -fstack-protector-strong -no-canonical-prefixes -march=armv7-a -mfloat-abi=softfp -mfpu=vfpv3-d16 -fno-integrated-as -mthumb -Wa,--noexecstack -Wformat -Werror=format-security   -std=gnu++11 -O0 -fno-limit-debug-info  -fPIC -MD -MT CMakeFiles/link.dir/link.cpp.o -MF CMakeFiles\link.dir\link.cpp.o.d -o CMakeFiles/link.dir/link.cpp.o -c F:\workplace\duanbinbin\pano-share-sdk-android\PanoShareSDKAndroid\DemoJNI\src\main\cpp\link.cpp
clang++.exe: error: unable to execute command: program not executable
clang++.exe: error: assembler command failed with exit code 1 (use -v to see invocation)
ninja: build stopped: su
bcommand failed.
:DemoJNI:externalNativeBuildDebug FAILED
:DemoJNI:buildInfoGeneratorDebug

FAILURE: Build failed with an exception.

 * What went wrong:
Execution failed for task ':DemoJNI:externalNativeBuildDebug'.
> Build command failed.
  Error while executing process D:\devTools\AndroidSDK\cmake\3.6.4111459\bin\cmake.exe with arguments {--build F:\workplace\duanbinbin\pano-share-sdk-android\PanoShareSDKAndroid\DemoJNI\.externalNativeBuild\cmake\debug\armeabi-v7a --target link}
  [1/1] Re-running CMake...
  CMake Warning at D:/devTools/AndroidSDK/ndk-bundle/build/cmake/android.toolchain.cmake:63 (message):
    Using custom NDK path (ANDROID_NDK is set):
    D:\devTools\AndroidSDK\ndk-bundle
  Call Stack (most recent call first):
    F:/workplace/duanbinbin/pano-share-sdk-android/PanoShareSDKAndroid/DemoJNI/.externalNativeBuild/cmake/debug/armeabi-v7a/CMakeFiles/3.6.0-rc2/CMakeSystem.cmake:6 (include)
    CMakeLists.txt

解决方式如下:

  • 在项目目录下\app.externalNativeBuild\cmake中找到CMakeSystem.cmake文件
    NDK使用遇到的那些事(持续更新当中)
  • 打开CMakeSystem.cmake文件,找到红色圆圈中的文件
    NDK使用遇到的那些事(持续更新当中)

  • 编辑android.toolchain.cmake文件,查找# Toolchain.关键字

# Toolchain.
if(CMAKE_HOST_SYSTEM_NAME STREQUAL Linux)
  set(ANDROID_HOST_TAG linux-x86_64)
elseif(CMAKE_HOST_SYSTEM_NAME STREQUAL Darwin)
  set(ANDROID_HOST_TAG darwin-x86_64)
elseif(CMAKE_HOST_SYSTEM_NAME STREQUAL Windows)
   #set(ANDROID_HOST_TAG windows-x86_64)
   set(ANDROID_HOST_TAG windows)
endif()

修改set(ANDROID_HOST_TAG windows-x86_64)为set(ANDROID_HOST_TAG windows)即可。

相关标签: NDK