After I updated my Android Studio it is giving me build command failed error. It gives me the following build error :
Build command failed.
Error while executing process /Users/bhaskarrajaryal/Library/Android/sdk/cmake/3.6.4111459/bin/cmake with arguments {--build /Users/bhaskarrajaryal/AndroidStudioProjects/wowtime/app/.externalNativeBuild/cmake/debug/armeabi-v7a --target baseUrl}
[1/1] Linking CXX shared library ../../../../build/intermediates/cmake/debug/obj/armeabi-v7a/libbaseUrl.so
FAILED: : && /Users/bhaskarrajaryal/Library/Android/sdk/ndk-bundle/toolchains/llvm/prebuilt/darwin-x86_64/bin/clang++ --target=armv7-none-linux-androideabi --gcc-toolchain=/Users/bhaskarrajaryal/Library/Android/sdk/ndk-bundle/toolchains/arm-linux-androideabi-4.9/prebuilt/darwin-x86_64 --sysroot=/Users/bhaskarrajaryal/Library/Android/sdk/ndk-bundle/sysroot -fPIC -isystem /Users/bhaskarrajaryal/Library/Android/sdk/ndk-bundle/sysroot/usr/include/arm-linux-androideabi -D__ANDROID_API__=16 -g -DANDROID -ffunction-sections -funwind-tables -fstack-protector-strong -no-canonical-prefixes -march=armv7-a -mfloat-abi=softfp -mfpu=vfpv3-d16 -mthumb -Wa,--noexecstack -Wformat -Werror=format-security -std=c++11 -O0 -fno-limit-debug-info -Wl,--exclude-libs,libgcc.a -Wl,--exclude-libs,libatomic.a -nostdlib++ --sysroot /Users/bhaskarrajaryal/Library/Android/sdk/ndk-bundle/platforms/android-16/arch-arm -Wl,--build-id -Wl,--warn-shared-textrel -Wl,--fatal-warnings -Wl,--fix-cortex-a8 -Wl,--exclude-libs,libunwind.a -L/Users/bhaskarrajaryal/Library/Android/sdk/ndk-bundle/sources/cxx-stl/llvm-libc++/libs/armeabi-v7a -Wl,--no-undefined -Wl,-z,noexecstack -Qunused-arguments -Wl,-z,relro -Wl,-z,now -shared -Wl,-soname,libbaseUrl.so -o ../../../../build/intermediates/cmake/debug/obj/armeabi-v7a/libbaseUrl.so CMakeFiles/baseUrl.dir/src/cpp/baseUrl.cpp.o -llog -latomic -lm "/Users/bhaskarrajaryal/Library/Android/sdk/ndk-bundle/sources/cxx-stl/gnu-libstdc++/4.9/libs/armeabi-v7a/libgnustl_static.a" && :
/Users/bhaskarrajaryal/Library/Android/sdk/ndk-bundle/sources/cxx-stl/llvm-libc++/include/stdexcept:136: error: undefined reference to 'std::logic_error::logic_error(char const*)'
clang++: error: linker command failed with exit code 1 (use -v to see invocation)
ninja: build stopped: subcommand failed.
Had the same issue after the update. I did a clean build (under Build > Clean Project) then restarted android studio with the option "Invalidate and Restart" under File > Invalidate Caches/Restart. It run well after that
Build-->Refresh Linked C++ Projects
Build Project
Try to do this:
Step 1: Safely delete the build folder from app directory.
Step 2: In Android Studio, File -> Invalidate Caches / Restart
Step 3: Build -> Clean Project Then Build -> Rebuild Project. so build folder will be regenerated and hope so error is gone.
Related
I have to to build opencv from source due to opencv_contrib. Although I have tried many tutorials, I faild to build opencv from source.
The code I used:
cmake -G"MinGW Makefiles" -DANDROID_NDK=D:/androidNDK/android-ndk-r22b -DANDROID_SDK_ROOT=D:/android-sdk -DCMAKE_TOOLCHAIN_FILE=D:/androidNDK/android-ndk-r22b/build/cmake/android.toolchain.cmake -DBUILD_EXAMPLES=OFF -DBUILD_TESTS=OFF -DBUILD_PERF_TESTS=OFF D:/OpenCV455/opencv-4.5.5
General configuration:
-- General configuration for OpenCV 4.5.5 =====================================
-- Version control: unknown
--
-- Platform:
-- Timestamp: 2022-11-19T00:58:08Z
-- Host: Windows 10.0.19043 AMD64
-- Target: Android 1 armv7-a
-- CMake: 3.21.3
-- CMake generator: MinGW Makefiles
-- CMake build tool: D:/MinGW1/mingw64/bin/mingw32-make.exe
-- Configuration: Release
--
-- CPU/HW features:
-- Baseline: NEON
-- requested: DETECT
--
-- C/C++:
-- Built as dynamic libs?: NO
-- C++ standard: 11
-- C++ Compiler: D:/androidNDK/android-ndk-r22b/toolchains/llvm/prebuilt/windows-x86_64/bin/clang++.exe (ver 11.0.5)
-- C++ flags (Release): -g -DANDROID -fdata-sections -ffunction-sections -funwind-tables -fstack-protector-strong -no-canonical-prefixes -D_FORTIFY_SOURCE=2 -march=armv7-a -mthumb -Wformat -Werror=format-security -fsigned-char -W -Wall -Werror=return-type -Werror=non-virtual-dtor -Werror=address -Werror=sequence-point -Wformat -Werror=format-security -Wmissing-declarations -Wmissing-prototypes -Wstrict-prototypes -Wundef -Winit-self -Wpointer-arith -Wshadow -Wsign-promo -Wuninitialized -Winconsistent-missing-override -Wno-delete-non-virtual-dtor -Wno-unnamed-type-template-args -Wno-comment -Wno-deprecated-enum-enum-conversion -Wno-deprecated-anon-enum-enum-conversion -fdiagnostics-show-option -Qunused-arguments -fvisibility=hidden -fvisibility-inlines-hidden -Oz -DNDEBUG -DNDEBUG
-- C++ flags (Debug): -g -DANDROID -fdata-sections -ffunction-sections -funwind-tables -fstack-protector-strong -no-canonical-prefixes -D_FORTIFY_SOURCE=2 -march=armv7-a -mthumb -Wformat -Werror=format-security -fsigned-char -W -Wall -Werror=return-type -Werror=non-virtual-dtor -Werror=address -Werror=sequence-point -Wformat -Werror=format-security -Wmissing-declarations -Wmissing-prototypes -Wstrict-prototypes -Wundef -Winit-self -Wpointer-arith -Wshadow -Wsign-promo -Wuninitialized -Winconsistent-missing-override -Wno-delete-non-virtual-dtor -Wno-unnamed-type-template-args -Wno-comment -Wno-deprecated-enum-enum-conversion -Wno-deprecated-anon-enum-enum-conversion -fdiagnostics-show-option -Qunused-arguments -fvisibility=hidden -fvisibility-inlines-hidden -O0 -fno-limit-debug-info -DDEBUG -D_DEBUG
-- C Compiler: D:/androidNDK/android-ndk-r22b/toolchains/llvm/prebuilt/windows-x86_64/bin/clang.exe
-- C flags (Release): -g -DANDROID -fdata-sections -ffunction-sections -funwind-tables -fstack-protector-strong -no-canonical-prefixes -D_FORTIFY_SOURCE=2 -march=armv7-a -mthumb -Wformat -Werror=format-security -fsigned-char -W -Wall -Werror=return-type -Werror=non-virtual-dtor -Werror=address -Werror=sequence-point -Wformat -Werror=format-security -Wmissing-declarations -Wmissing-prototypes -Wstrict-prototypes -Wundef -Winit-self -Wpointer-arith -Wshadow -Wsign-promo -Wuninitialized -Winconsistent-missing-override -Wno-delete-non-virtual-dtor -Wno-unnamed-type-template-args -Wno-comment -Wno-deprecated-enum-enum-conversion -Wno-deprecated-anon-enum-enum-conversion -fdiagnostics-show-option -Qunused-arguments -fvisibility=hidden -fvisibility-inlines-hidden -Oz -DNDEBUG -DNDEBUG
-- C flags (Debug): -g -DANDROID -fdata-sections -ffunction-sections -funwind-tables -fstack-protector-strong -no-canonical-prefixes -D_FORTIFY_SOURCE=2 -march=armv7-a -mthumb -Wformat -Werror=format-security -fsigned-char -W -Wall -Werror=return-type -Werror=non-virtual-dtor -Werror=address -Werror=sequence-point -Wformat -Werror=format-security -Wmissing-declarations -Wmissing-prototypes -Wstrict-prototypes -Wundef -Winit-self -Wpointer-arith -Wshadow -Wsign-promo -Wuninitialized -Winconsistent-missing-override -Wno-delete-non-virtual-dtor -Wno-unnamed-type-template-args -Wno-comment -Wno-deprecated-enum-enum-conversion -Wno-deprecated-anon-enum-enum-conversion -fdiagnostics-show-option -Qunused-arguments -fvisibility=hidden -fvisibility-inlines-hidden -O0 -fno-limit-debug-info -DDEBUG -D_DEBUG
-- Linker flags (Release): -Wl,--exclude-libs,libgcc.a -Wl,--exclude-libs,libgcc_real.a -Wl,--exclude-libs,libatomic.a -static-libstdc++ -Wl,--build-id=sha1 -Wl,--no-rosegment -Wl,--fatal-warnings -Wl,--exclude-libs,libunwind.a -Wl,--no-undefined -Qunused-arguments -Wl,--as-needed
-- Linker flags (Debug): -Wl,--exclude-libs,libgcc.a -Wl,--exclude-libs,libgcc_real.a -Wl,--exclude-libs,libatomic.a -static-libstdc++ -Wl,--build-id=sha1 -Wl,--no-rosegment -Wl,--fatal-warnings -Wl,--exclude-libs,libunwind.a -Wl,--no-undefined -Qunused-arguments -Wl,--as-needed
-- ccache: NO
-- Precompiled headers: NO
-- Extra dependencies: z dl m log
-- 3rdparty dependencies: libcpufeatures libprotobuf ade ittnotify libjpeg-turbo libwebp libpng libtiff libopenjp2 IlmImf quirc tegra_hal
--
-- OpenCV modules:
-- To be built: calib3d core dnn features2d flann gapi highgui imgcodecs imgproc java ml objdetect photo stitching video videoio
-- Disabled: world
-- Disabled by dependency: -
-- Unavailable: python2 python3 ts
-- Applications: android_examples
-- Documentation: NO
-- Non-free algorithms: NO
--
-- Android NDK: D:/androidNDK/android-ndk-r22b (ver 22.1.7171670)
-- Android ABI: armeabi-v7a
-- NDK toolchain: arm-linux-androideabi-clang
-- STL type: c++_static
-- Native API level: 16
-- Android SDK: D:/android-sdk (tools: 25.2.5 build tools: 33.0.0)
-- android tool: D:/android-sdk/tools/android.bat
-- SDK target: android-21
-- Projects build scripts: Ant/Eclipse compatible
--
-- GUI: NONE
--
-- Media I/O:
-- ZLib: z (ver 1.2.11)
-- JPEG: build-libjpeg-turbo (ver 2.1.2-62)
-- WEBP: build (ver encoder: 0x020f)
-- PNG: build (ver 1.6.37)
-- TIFF: build (ver 42 - 4.2.0)
-- JPEG 2000: build (ver 2.4.0)
-- OpenEXR: build (ver 2.3.0)
-- HDR: YES
-- SUNRASTER: YES
-- PXM: YES
-- PFM: YES
--
-- Video I/O:
--
-- Parallel framework: pthreads
--
-- Trace: YES (with Intel ITT)
--
-- Other third-party libraries:
-- Custom HAL: YES (carotene (ver 0.0.1))
-- Protobuf: build (3.19.1)
--
-- Python (for build): D:/Python37/python.exe
--
-- Java: export all functions
-- ant: D:/apache-ant-1.9.16/bin/ant.bat (ver 1.9.16)
-- Java wrappers: YES
-- Java tests: NO
--
-- Install to: D:/OpenCV455/buil36/install
-----------------------------------------------------------------**
The errors I get after running 'mingw32-make':
[97%] Built target opencv_java_android_source_copy
[97%]Generating OpenCV Android library project. SDK target:
[97%] Bui1ding OpenCV Android library project
[subant] No sub-builds to iterate on
Target '-code-gen' failed with message 'The following error occurred while executing this line:
D:\android-sdk\tools\ant\build.xml:655: null returned: -1073741819'.
Cannot execute '-compile' - '-code-gen' failed or was not executed.
Cannot execute '-dex' - '-compile' failed or was not executed.
Cannot execute '-package' - '-dex' failed or was not executed.
Cannot execute '-do-debug' - '-package' failed or was not executed.
Cannot execute 'debug' - '-do-debug' failed or was not executed.
BUILD FAILED
D:\android-sdk\tools\ant\build.xml:649: The following error occurred while executing this line:
D:\android-sdk\tools\ant\build.xml:655: null returned: -1073741819
Total time: 2 seconds
mingw32-make[2]: *** [modules\java\android_sdk\CMakeFiles\opencv_java_android.dir\build.make:77: bin/classes.jar] Error 1
mingw32-make[1]: *** [CMakeFiles\Makefile2:2689: modules/java/android_sdk/CMakeFiles/opencv_java_android.dir/all] Error 2
I get similar errors with ninja.
[1568/1595] Building OpenCV Android library project
FAILED: bin/classes.jar CMakeFiles/dephelper/opencv_java_android D:/OpenCV455/build36/bin/classes.jar D:/OpenCV455/build36/CMakeFiles/dephelper/opencv_java_android
cmd.exe /C "cd /D D:\OpenCV455\build36\android_sdk && D:\apache-ant-1.9.16\bin\ant.bat -q -noinput -k debug -Djava.target=1.6 -Djava.source=1.6 && D:\cmake-3.21.3\bin\cmake.exe -E touch D:/OpenCV455/build36/CMakeFiles/dephelper/opencv_java_android"
[subant] No sub-builds to iterate on
Target '-code-gen' failed with message 'The following error occurred while executing this line:
D:\android-sdk\tools\ant\build.xml:655: null returned: -1073741819'.
Cannot execute '-compile' - '-code-gen' failed or was not executed.
Cannot execute '-dex' - '-compile' failed or was not executed.
Cannot execute '-package' - '-dex' failed or was not executed.
Cannot execute '-do-debug' - '-package' failed or was not executed.
Cannot execute 'debug' - '-do-debug' failed or was not executed.
BUILD FAILED
D:\android-sdk\tools\ant\build.xml:649: The following error occurred while executing this line:
D:\android-sdk\tools\ant\build.xml:655: null returned: -1073741819
Total time: 1 second
[1572/1595] Building CXX object modules/gapi/CMakeFiles/opencv_perf_gapi.dir/perf/gpu/gapi_core_perf_tests_gpu.cpp.o
ninja: build stopped: subcommand failed.
here is the code with error.
in build.ninja file:
# Custom command for bin\classes.jar
build bin/classes.jar CMakeFiles/dephelper/opencv_java_android | ${cmake_ninja_workdir}bin/classes.jar ${cmake_ninja_workdir}CMakeFiles/dephelper/opencv_java_android: CUSTOM_COMMAND CMakeFiles/dephelper/opencv_java_android_source_copy android_sdk/build.xml android_sdk/local.properties android_sdk/proguard-project.txt android_sdk/project.properties android_sdk/AndroidManifest.xml || modules/java/android_sdk/opencv_java_android_source_copy modules/java_bindings_generator/gen_opencv_java_source
COMMAND = cmd.exe /C "cd /D D:\OpenCV455\build34\android_sdk && D:\apache-ant-1.9.16\bin\ant.bat -q -noinput -k debug -Djava.target=1.6 -Djava.source=1.6 && D:\cmake-3.21.3\bin\cmake.exe -E touch D:/OpenCV455/build34/CMakeFiles/dephelper/opencv_java_android"
DESC = Building OpenCV Android library project
restat = 1
in build.cmake file:
bin/classes.jar: CMakeFiles/dephelper/opencv_java_android_source_copy
bin/classes.jar: android_sdk/build.xml
bin/classes.jar: android_sdk/local.properties
bin/classes.jar: android_sdk/proguard-project.txt
bin/classes.jar: android_sdk/project.properties
bin/classes.jar: android_sdk/AndroidManifest.xml
#$(CMAKE_COMMAND) -E cmake_echo_color --switch=$(COLOR) --blue --bold --progress-dir=D:\OpenCV455\build41\CMakeFiles --progress-num=$(CMAKE_PROGRESS_1) "Building OpenCV Android library project"
cd /d D:\OpenCV455\build41\android_sdk && call D:\apache-ant-1.9.16\bin\ant.bat -q -noinput -k debug -Djava.target=1.6 -Djava.source=1.6
cd /d D:\OpenCV455\build41\android_sdk && D:\cmake-3.21.3\bin\cmake.exe -E touch D:/OpenCV455/build41/CMakeFiles/dephelper/opencv_java_android
CMakeFiles/dephelper/opencv_java_android: bin/classes.jar
in build.xml file:
<do-only-if-manifest-hasCode
elseText="hasCode = false. Skipping aidl/renderscript/R.java">
<echo level="info">Handling aidl files...</echo>
<aidl executable="${aidl}"
framework="${project.target.framework.aidl}"
libraryBinAidlFolderPathRefid="project.library.bin.aidl.folder.path"
genFolder="${gen.absolute.dir}"
aidlOutFolder="${out.aidl.absolute.dir}">
<source path="${source.absolute.dir}"/>
</aidl>
How to fix it?
I try to find solutions for similar problem, and here maybe the only similar one. The developer suggetsted that:
Android SDK: not used, projects are not built
After that message Java-based projects should be skipped completely.
Try to upgrade your Android SDK "BuildTools".
CMAKE_CONFIG_GENERATOR="MinGW Makefiles"
There is ninja build tool in Android NDK. Use cmake -GNinja ... for better experience.
I don't quite grasp how to do, My build tools version is 33.0.0.
I found two options:
shell script (reference)
Install Git Bash and set it in PATH (C:\Program Files\Git\cmd)
Install Cmake 3.24.3 and set it in PATH (C:\Program Files\CMake\bin)
Install java and set it in PATH (C:\Program Files\Java\jdk1.8.0_202\bin), create variable JAVA_HOME(C:\Program Files\Java\jdk1.8.0_202)
Install C compiler (mingw or Visual Studio or etc.). If you use mingw, then you will need to install: mingw32-base-bin,
mingw32-gcc-fortran-bin,
mingw32-gcc-g++-bin,
mingw32-gcc-objc-bin,
msys-base-bin. And then in PATH add C:\MinGW\bin
You may also need WSL for Windows, but I did it just through Git Bash
Create a script in an empty folder and name it build.sh:
#!/bin/bash -e
myRepo=$(pwd)
CMAKE_GENERATOR_OPTIONS=-G"Visual Studio 17 2022"
#CMAKE_GENERATOR_OPTIONS=-G"Visual Studio 15 2017 Win64"
#CMAKE_GENERATOR_OPTIONS=(-G"Visual Studio 16 2019" -A x64) # CMake 3.14+ is required
if [ ! -d "$myRepo/gstreamer" ]; then
echo "cloning gstreamer"
git clone https://github.com/GStreamer/gstreamer.git
else
cd gstreamer
git pull --rebase
cd ..
fi
if [ ! -d "$myRepo/openexr" ]; then
echo "cloning openexr"
git clone https://github.com/AcademySoftwareFoundation/openexr.git
else
cd openexr
git pull --rebase
cd ..
fi
if [ ! -d "$myRepo/openblas" ]; then
echo "cloning openblas"
git clone https://github.com/xianyi/OpenBLAS.git
else
cd openblas
git pull --rebase
cd ..
fi
if [ ! -d "$myRepo/eigen" ]; then
echo "cloning eigen"
git clone https://gitlab.com/libeigen/eigen.git
else
cd eigen
git pull --rebase
cd ..
fi
if [ ! -d "$myRepo/opencv" ]; then
echo "cloning opencv"
git clone https://github.com/opencv/opencv.git
else
cd opencv
git pull --rebase
cd ..
fi
if [ ! -d "$myRepo/opencv_contrib" ]; then
echo "cloning opencv_contrib"
git clone https://github.com/opencv/opencv_contrib.git
else
cd opencv_contrib
git pull --rebase
cd ..
fi
if [ ! -d "$myRepo/tesseract" ]; then
echo "cloning tesseract"
git clone https://github.com/tesseract-ocr/tesseract.git
else
cd tesseract
git pull --rebase
cd ..
fi
RepoSource=opencv
mkdir -p build_opencv
pushd build_opencv
CMAKE_OPTIONS=( -DBUILD_opencv_world:BOOL=OFF -DBUILD_JAVA:BOOL=ON -DBUILD_PERF_TESTS:BOOL=OFF -DBUILD_TESTS:BOOL=OFF -DBUILD_DOCS:BOOL=OFF -DWITH_CUDA:BOOL=OFF -DBUILD_EXAMPLES:BOOL=OFF -DINSTALL_CREATE_DISTRIB=ON)
set -x
cmake "${CMAKE_GENERATOR_OPTIONS[#]}" "${CMAKE_OPTIONS[#]}" -DOPENCV_EXTRA_MODULES_PATH="$myRepo"/opencv_contrib/modules -DCMAKE_INSTALL_PREFIX="$myRepo/install/$RepoSource" "$myRepo/$RepoSource"
echo "************************* $Source_DIR -->debug"
cmake --build . --config debug
echo "************************* $Source_DIR -->release"
cmake --build . --config release
cmake --build . --target install --config release
cmake --build . --target install --config debug
popd
Open Git Bash, open the folder with our script in it and write bash build.sh
If you have following error syntax error: unexpected end of file, then here is the solution
As result we get opencv_java460.dll and opencv-460.jar
Cmake with ninja (taken from here, but modified)
Here I will describe what I used to build (it's not a fact that this is all I need or specific versions, but it worked for me):
Install Python and set it in PATH (C:\Users\volce\AppData\Local\Programs\Python\Python311\Scripts\ и C:\Users\volce\AppData\Local\Programs\Python\Python311\)
Install java 8 and set it in PATH and in JAVA_HOME (see above)
Install Cmake 3.24.3 (I haven't tried it on another version) and set it in PATH (see above)
Download NDK r25, unzip and add an environment variable ANDROID_NDK: C:\Users\volce\AppData\Local\Android\Sdk\ndk\android-ndk-r25b
Download SDK tools r25.2.3, platform-tools r25.0.1 and build-tools r25.0.1
In the SDK folder, replace the contents of the tools, build-tools and platform-tools folders with the downloaded ones
Also, in PATH I added: C:\Users\volce\AppData\Local\Android\Sdk\tools and C:\Users\volce\AppData\Local\Android\Sdk\platform-tools
Adding environment variables: ANDROID_HOME and ANDROID_SDK_ROOT, where we specify the path to the SDK (for example, C:\Users\volce\AppData\Local\Android\Sdk)
Download ant and set it in PATH (C:\apache-ant-1.10.12\bin и C:\apache-ant-1.10.12\lib) and create ANT_HOME (C:\apache-ant-1.10.12)
Download MinGw, install the necessary packages and set it in PATH (see above)
Download and install Visual Studio
What did I do next
Created a folder for our task
In it we do git clone https://github.com/opencv/opencv.git and git clone https://github.com/opencv/opencv_contrib.git
In the folder with opencv, go to samples\android and in the file CMakeLists.txt deleting add_subdirectory(15-puzzle) (because of this, I did not build)
Create a build folder in our root folder (which was created for building opencv)
We go into it and do git clone https://github.com/ninja-build/ninja.git
Open Visual Studio. In it: Tools->Command Line->Developer Command Line. In the command line, write the path to the created folder build and write python configure.py --bootstrap. This is how we configured ninja
Being in our build folder in the console, we write the following(don't forget to change the paths to your own):
cmake -GNinja -DCMAKE_MAKE_PROGRAM=E:\OpenCV\build\ninja.exe -DCMAKE_INSTALL_PREFIX=E:\OpenCV\install -DANDROID_PROJECTS_BUILD_TYPE="ANT" -DBUILD_ANDROID_PROJECTS=ON -DBUILD_EXAMPLES:BOOL=OFF -DBUILD_TESTS:BOOL=OFF -DBUILD_PERF_TESTS:BOOL=OFF -DBUILD_JAVA=ON -DBUILD_opencv_java=ON -DBUILD_SHARED_LIBS:BOOL=OFF -DBUILD_FAT_JAVA_LIB=ON -DBUILD_PYTHON:BOOL=OFF -DINSTALL_ANDROID_EXAMPLES:BOOL=OFF -DANDROID_EXAMPLES_WITH_LIBS:BOOL=OFF -DBUILD_DOCS:BOOL=OFF -DWITH_OPENCL=ON -DANDROID_NDK_HOST_X64=ON -DANDROID_NDK=C:/Users/volce/AppData/Local/Android/Sdk/ndk/android-ndk-r25b/ -DANDROID_SDK=C:/Users/volce/AppData/Local/Android/Sdk -DCMAKE_TOOLCHAIN_FILE=C:/Users/volce/AppData/Local/Android/Sdk/ndk/android-ndk-r25b/build/cmake/android.toolchain.cmake -DANDROID_TOOLCHAIN=clang -DANDROID_STL=c++_static -DANDROID_ARM_NEON=ON -DANDROID_ABI='arm64-v8a, armeabi-v7a, x86_64, x86' -DANDROID_NDK_HOST_X64=ON -DBUILD_opencv_python3:BOOL=OFF -DBUILD_opencv_python2:BOOL=OFF -DOPENCV_EXTRA_MODULES_PATH=E:/OpenCV/opencv_contrib/modules -DOPENCV_ENABLE_NONFREE=ON -DANDROID_NATIVE_API_LEVEL=25 -DANDROID_TARGET_SDK_VERSION=32 -DANDROID_MIN_SDK_VERSION=21 E:\OpenCV\opencv
After execution , write ninja -j8 in console
After waiting for the execution of the previous command, we write ninja install
As result we get the OpenCV SDK for Android
How to integrate OpenCV 4.6.0 in your project -> https://www.youtube.com/watch?v=bR7lL886-uc
My project stops working after updating gradle.
I'm using a C library in Android though JNI.
Using Cmake to compile and join the libraries
Before, it compiled and linked without a problem, but now there is an error at link time when building the project.
It throw this error:
/home/my_user/Documents/Proyects/optandroid/app/src/main/cpp/kotlin-jni.c:152: error: undefined reference to 'find_best_order'
This is an extended error message that android studio also gives after trying to build the project:
> Task :app:externalNativeBuildDebug FAILED
Build multiple targets main_armeabi-v7a this_library_armeabi-v7a process_control_armeabi-v7a
ninja: Entering directory `/home/my_user/Documents/Proyects/optandroid/app/.cxx/cmake/debug/armeabi-v7a'
[1/1] Linking C shared library /home/my_user/Documents/Proyects/optandroid/app/build/intermediates/cmake/debug/obj/armeabi-v7a/libthis_library.so
FAILED: /home/my_user/Documents/Proyects/optandroid/app/build/intermediates/cmake/debug/obj/armeabi-v7a/libthis_library.so
: && /home/my_user/Android/Sdk/ndk/21.1.6352462/toolchains/llvm/prebuilt/linux-x86_64/bin/clang --target=armv7-none-linux-androideabi19 --gcc-toolchain=/home/my_user/Android/Sdk/ndk/21.1.6352462/toolchains/llvm/prebuilt/linux-x86_64 --sysroot=/home/my_user/Android/Sdk/ndk/21.1.6352462/toolchains/llvm/prebuilt/linux-x86_64/sysroot -fPIC -g -DANDROID -fdata-sections -ffunction-sections -funwind-tables -fstack-protector-strong -no-canonical-prefixes -D_FORTIFY_SOURCE=2 -march=armv7-a -mthumb -Wformat -Werror=format-security -O0 -fno-limit-debug-info -Wl,--exclude-libs,libgcc.a -Wl,--exclude-libs,libgcc_real.a -Wl,--exclude-libs,libatomic.a -static-libstdc++ -Wl,--build-id -Wl,--fatal-warnings -Wl,--exclude-libs,libunwind.a -Wl,--no-undefined -Qunused-arguments -shared -Wl,-soname,libthis_library.so -o /home/my_user/Documents/Proyects/optandroid/app/build/intermediates/cmake/debug/obj/armeabi-v7a/libthis_library.so CMakeFiles/this_library.dir/kotlin-jni.c.o used_library/src/libmodule_used_library.a /home/my_user/Documents/Proyects/optandroid/app/build/intermediates/cmake/debug/obj/armeabi-v7a/libprocess_control.so -latomic -lm && :
/home/my_user/Android/Sdk/ndk/21.1.6352462/toolchains/llvm/prebuilt/linux-x86_64/lib/gcc/arm-linux-androideabi/4.9.x/../../../../arm-linux-androideabi/bin/ld: error: used_library/src/libmodule_used_library.a: member at 3324 is not an ELF object
/home/my_user/Documents/Proyects/optandroid/app/src/main/cpp/kotlin-jni.c:152: error: undefined reference to 'find_best_order'
clang: error: linker command failed with exit code 1 (use -v to see invocation)
ninja: build stopped: subcommand failed.
Execution failed for task ':app:externalNativeBuildDebug'.
> Build command failed.
Error while executing process ninja with arguments {-C /home/my_user/Documents/Proyects/optandroid/app/.cxx/cmake/debug/armeabi-v7a main this_library process_control}
ninja: Entering directory `/home/my_user/Documents/Proyects/optandroid/app/.cxx/cmake/debug/armeabi-v7a'
[1/1] Linking C shared library /home/my_user/Documents/Proyects/optandroid/app/build/intermediates/cmake/debug/obj/armeabi-v7a/libthis_library.so
FAILED: /home/my_user/Documents/Proyects/optandroid/app/build/intermediates/cmake/debug/obj/armeabi-v7a/libthis_library.so
: && /home/my_user/Android/Sdk/ndk/21.1.6352462/toolchains/llvm/prebuilt/linux-x86_64/bin/clang --target=armv7-none-linux-androideabi19 --gcc-toolchain=/home/my_user/Android/Sdk/ndk/21.1.6352462/toolchains/llvm/prebuilt/linux-x86_64 --sysroot=/home/my_user/Android/Sdk/ndk/21.1.6352462/toolchains/llvm/prebuilt/linux-x86_64/sysroot -fPIC -g -DANDROID -fdata-sections -ffunction-sections -funwind-tables -fstack-protector-strong -no-canonical-prefixes -D_FORTIFY_SOURCE=2 -march=armv7-a -mthumb -Wformat -Werror=format-security -O0 -fno-limit-debug-info -Wl,--exclude-libs,libgcc.a -Wl,--exclude-libs,libgcc_real.a -Wl,--exclude-libs,libatomic.a -static-libstdc++ -Wl,--build-id -Wl,--fatal-warnings -Wl,--exclude-libs,libunwind.a -Wl,--no-undefined -Qunused-arguments -shared -Wl,-soname,libthis_library.so -o /home/my_user/Documents/Proyects/optandroid/app/build/intermediates/cmake/debug/obj/armeabi-v7a/libthis_library.so CMakeFiles/this_library.dir/kotlin-jni.c.o used_library/src/libmodule_used_library.a /home/my_user/Documents/Proyects/optandroid/app/build/intermediates/cmake/debug/obj/armeabi-v7a/libprocess_control.so -latomic -lm && :
/home/my_user/Android/Sdk/ndk/21.1.6352462/toolchains/llvm/prebuilt/linux-x86_64/lib/gcc/arm-linux-androideabi/4.9.x/../../../../arm-linux-androideabi/bin/ld: error: used_library/src/libmodule_used_library.a: member at 3324 is not an ELF object
/home/my_user/Documents/Proyects/optandroid/app/src/main/cpp/kotlin-jni.c:152: error: undefined reference to 'find_best_order'
clang: error: linker command failed with exit code 1 (use -v to see invocation)
ninja: build stopped: subcommand failed.
This is the CmakeLists.txt:
cmake_minimum_required(VERSION 3.15)
project(Optandroid)
set(CMAKE_C_STANDARD 99)
add_subdirectory(used_library)
add_library(this_library
SHARED
kotlin-jni.c
)
# Include libraries needed for kotlin-jni lib
target_link_libraries(this_library
process_library
android
log)
used_library is the library directory, it builds the library process_library, and this_library it is what I use for JNI.
This is a pure C project, nothing of C++, so it is not the problem of C++ changing the names of functions.
I corroborated that the problem starts by updating gradle in the project by taking an older proyect which use this library in exactly the same way, and just making the update, it works before, but has the exactly same error after.
Thanks in advance.
At the end the problem was the NDK version. I just updated NDK to the newest version and started worked like before.
I have installed android studio 3.1.2 and creates My application app but it says this:
Build command failed.
Error while executing process C:\Users\Rajeev Sarraf\AppData\Local\Android\Sdk\cmake\3.6.4111459\bin\cmake.exe with arguments {-HC:\Users\Rajeev Sarraf\ApkProjects\MyApplication\app -BC:\Users\Rajeev Sarraf\ApkProjects\MyApplication\app\.externalNativeBuild\cmake\release\armeabi-v7a -DANDROID_ABI=armeabi-v7a -DANDROID_PLATFORM=android-15 -DCMAKE_LIBRARY_OUTPUT_DIRECTORY=C:\Users\Rajeev Sarraf\ApkProjects\MyApplication\app\build\intermediates\cmake\release\obj\armeabi-v7a -DCMAKE_BUILD_TYPE=Release -DANDROID_NDK=C:\Users\Rajeev Sarraf\AppData\Local\Android\Sdk\ndk-bundle -DCMAKE_CXX_FLAGS= -DCMAKE_TOOLCHAIN_FILE=C:\Users\Rajeev Sarraf\AppData\Local\Android\Sdk\ndk-bundle\build\cmake\android.toolchain.cmake -DCMAKE_MAKE_PROGRAM=C:\Users\Rajeev Sarraf\AppData\Local\Android\Sdk\cmake\3.6.4111459\bin\ninja.exe -GAndroid Gradle - Ninja}
-- Check for working C compiler: C:/Users/Rajeev Sarraf/AppData/Local/Android/Sdk/ndk-bundle/toolchains/llvm/prebuilt/windows-x86_64/bin/clang.exe
-- Check for working C compiler: C:/Users/Rajeev Sarraf/AppData/Local/Android/Sdk/ndk-bundle/toolchains/llvm/prebuilt/windows-x86_64/bin/clang.exe -- broken
/Users/Rajeev Sarraf/AppData/Local/Android/Sdk/ndk-bundle/toolchains/llvm/prebuilt/windows-x86_64/bin/clang.exe" is not able to compile a simple test program.
Open File
It fails with the following output:
Change Dir: C:/Users/Rajeev Sarraf/ApkProjects/MyApplication/app/.externalNativeBuild/cmake/release/armeabi-v7a/CMakeFiles/CMakeTmp
Run Build Command:"C:/Users/Rajeev
Sarraf/AppData/Local/Android/Sdk/cmake/3.6.4111459/bin/ninja.exe"
"cmTC_c2a5a"
[1/2] Building C object CMakeFiles/cmTC_c2a5a.dir/testCCompiler.c.o
FAILED:
C:\Users\RAJEEV~1\AppData\Local\Android\Sdk\NDK-BU~1\TOOLCH~1\llvm\prebuilt\WINDOW~1\bin\clang.exe
--target=armv7-none-linux-androideabi --gcc-toolchain="C:/Users/Rajeev
Sarraf/AppData/Local/Android/Sdk/ndk-bundle/toolchains/arm-linux-androideabi-4.9/prebuilt/windows-x86_64"
--sysroot="C:/Users/Rajeev
Sarraf/AppData/Local/Android/Sdk/ndk-bundle/sysroot" -isystem
C:/Users/Rajeev
Sarraf/AppData/Local/Android/Sdk/ndk-bundle/sysroot/usr/include/arm-linux-androideabi
-D__ANDROID_API__=15 -g -DANDROID -ffunction-sections -funwind-tables
-fstack-protector-strong -no-canonical-prefixes -march=armv7-a
-mfloat-abi=softfp -mfpu=vfpv3-d16 -mthumb -Wa,--noexecstack -Wformat
-Werror=format-security -o CMakeFiles/cmTC_c2a5a.dir/testCCompiler.c.o -c
"C:\Users\Rajeev
Sarraf\ApkProjects\MyApplication\app\.externalNativeBuild\cmake\release\armeabi-v7a\CMakeFiles\CMakeTmp\testCCompiler.c"
error: no such file or directory:
'Sarraf/AppData/Local/Android/Sdk/ndk-bundle/sysroot/usr/include/arm-linux-androideabi'
ninja: build stopped: subcommand failed.
CMake will not be able to correctly generate this project.
Call Stack (most recent call first):
CMakeLists.txt
-- Configuring incomplete, errors occurred!
See also "C:/Users/Rajeev Sarraf/ApkProjects/MyApplication/app/.externalNativeBuild/cmake/release/armeabi-v7a/CMakeFiles/CMakeOutput.log".
See also "C:/Users/Rajeev Sarraf/ApkProjects/MyApplication/app/.externalNativeBuild/cmake/release/armeabi-v7a/CMakeFiles/CMakeError.log".
Build command failed.
Error while executing process C:\Users\Rajeev Sarraf\AppData\Local\Android\Sdk\cmake\3.6.4111459\bin\cmake.exe with arguments {-HC:\Users\Rajeev Sarraf\ApkProjects\MyApplication\app -BC:\Users\Rajeev Sarraf\ApkProjects\MyApplication\app\.externalNativeBuild\cmake\debug\armeabi-v7a -DANDROID_ABI=armeabi-v7a -DANDROID_PLATFORM=android-15 -DCMAKE_LIBRARY_OUTPUT_DIRECTORY=C:\Users\Rajeev Sarraf\ApkProjects\MyApplication\app\build\intermediates\cmake\debug\obj\armeabi-v7a -DCMAKE_BUILD_TYPE=Debug -DANDROID_NDK=C:\Users\Rajeev Sarraf\AppData\Local\Android\Sdk\ndk-bundle -DCMAKE_CXX_FLAGS= -DCMAKE_TOOLCHAIN_FILE=C:\Users\Rajeev Sarraf\AppData\Local\Android\Sdk\ndk-bundle\build\cmake\android.toolchain.cmake -DCMAKE_MAKE_PROGRAM=C:\Users\Rajeev Sarraf\AppData\Local\Android\Sdk\cmake\3.6.4111459\bin\ninja.exe -GAndroid Gradle - Ninja}
-- Check for working C compiler: C:/Users/Rajeev Sarraf/AppData/Local/Android/Sdk/ndk-bundle/toolchains/llvm/prebuilt/windows-x86_64/bin/clang.exe
-- Check for working C compiler: C:/Users/Rajeev Sarraf/AppData/Local/Android/Sdk/ndk-bundle/toolchains/llvm/prebuilt/windows-x86_64/bin/clang.exe -- broken
/Users/Rajeev Sarraf/AppData/Local/Android/Sdk/ndk-bundle/toolchains/llvm/prebuilt/windows-x86_64/bin/clang.exe" is not able to compile a simple test program.
Open File
It fails with the following output:
Change Dir: C:/Users/Rajeev Sarraf/ApkProjects/MyApplication/app/.externalNativeBuild/cmake/debug/armeabi-v7a/CMakeFiles/CMakeTmp
Run Build Command:"C:/Users/Rajeev
Sarraf/AppData/Local/Android/Sdk/cmake/3.6.4111459/bin/ninja.exe"
"cmTC_f8247"
[1/2] Building C object CMakeFiles/cmTC_f8247.dir/testCCompiler.c.o
FAILED:
C:\Users\RAJEEV~1\AppData\Local\Android\Sdk\NDK-BU~1\TOOLCH~1\llvm\prebuilt\WINDOW~1\bin\clang.exe
--target=armv7-none-linux-androideabi --gcc-toolchain="C:/Users/Rajeev
Sarraf/AppData/Local/Android/Sdk/ndk-bundle/toolchains/arm-linux-androideabi-4.9/prebuilt/windows-x86_64"
--sysroot="C:/Users/Rajeev
Sarraf/AppData/Local/Android/Sdk/ndk-bundle/sysroot" -isystem
C:/Users/Rajeev
Sarraf/AppData/Local/Android/Sdk/ndk-bundle/sysroot/usr/include/arm-linux-androideabi
-D__ANDROID_API__=15 -g -DANDROID -ffunction-sections -funwind-tables
-fstack-protector-strong -no-canonical-prefixes -march=armv7-a
-mfloat-abi=softfp -mfpu=vfpv3-d16 -mthumb -Wa,--noexecstack -Wformat
-Werror=format-security -o CMakeFiles/cmTC_f8247.dir/testCCompiler.c.o -c
"C:\Users\Rajeev
Sarraf\ApkProjects\MyApplication\app\.externalNativeBuild\cmake\debug\armeabi-v7a\CMakeFiles\CMakeTmp\testCCompiler.c"
error: no such file or directory:
'Sarraf/AppData/Local/Android/Sdk/ndk-bundle/sysroot/usr/include/arm-linux-androideabi'
ninja: build stopped: subcommand failed.
CMake will not be able to correctly generate this project.
Call Stack (most recent call first):
CMakeLists.txt
-- Configuring incomplete, errors occurred!
See also "C:/Users/Rajeev Sarraf/ApkProjects/MyApplication/app/.externalNativeBuild/cmake/debug/armeabi-v7a/CMakeFiles/CMakeOutput.log".
See also "C:/Users/Rajeev Sarraf/ApkProjects/MyApplication/app/.externalNativeBuild/cmake/debug/armeabi-v7a/CMakeFiles/CMakeError.log".
it says 4 errors
anyone can please give a solution
I had the same Problem. I hope i can help u here.
Try to create a new project and change the project location. Its important, that the new project location, contain NO whitespace. Gradle cannot sync, if there is whitespace.
Jules
I have tried several days installing the NDK into Android Studio but it always gives me an error message saying that the build failed and I should install a c compiler. I installed the NDK via the SDK Manager by checking the NDK and C Make.
I have already tried completely reinstalling Android Studio and the NDK but that did not work as well -same error.
Something maybe worth mentioning is that if I do not check the C++ support during the project creation there are no errors(but no c++ support too:D).
What should I do because it kills my workflow?
Thank you very much
The Error Message:
Blockquote
External Native Build Issues
Build command failed.
Error while executing process C:\Users\Julius Debus\AppData\Local\Android\Sdk\cmake\3.6.4111459\bin\cmake.exe with arguments {-HC:\Users\Julius Debus\Desktop\MyApplication\app -BC:\Users\Julius Debus\Desktop\MyApplication\app.externalNativeBuild\cmake\release\armeabi-v7a -DANDROID_ABI=armeabi-v7a -DANDROID_PLATFORM=android-21 -DCMAKE_LIBRARY_OUTPUT_DIRECTORY=C:\Users\Julius Debus\Desktop\MyApplication\app\build\intermediates\cmake\release\obj\armeabi-v7a -DCMAKE_BUILD_TYPE=Release -DANDROID_NDK=C:\Users\Julius Debus\AppData\Local\Android\Sdk\ndk-bundle -DCMAKE_CXX_FLAGS=-std=c++11 -frtti -fexceptions -DCMAKE_TOOLCHAIN_FILE=C:\Users\Julius Debus\AppData\Local\Android\Sdk\ndk-bundle\build\cmake\android.toolchain.cmake -DCMAKE_MAKE_PROGRAM=C:\Users\Julius Debus\AppData\Local\Android\Sdk\cmake\3.6.4111459\bin\ninja.exe -GAndroid Gradle - Ninja}
-- Check for working C compiler: C:/Users/Julius Debus/AppData/Local/Android/Sdk/ndk-bundle/toolchains/llvm/prebuilt/windows-x86_64/bin/clang.exe
-- Check for working C compiler: C:/Users/Julius Debus/AppData/Local/Android/Sdk/ndk-bundle/toolchains/llvm/prebuilt/windows-x86_64/bin/clang.exe -- broken
It fails with the following output:
Change Dir: C:/Users/Julius Debus/Desktop/MyApplication/app/.externalNativeBuild/cmake/release/armeabi-v7a/CMakeFiles/CMakeTmp
Run Build Command:"C:/Users/Julius
Debus/AppData/Local/Android/Sdk/cmake/3.6.4111459/bin/ninja.exe"
"cmTC_a4b3d"
[1/2] Building C object CMakeFiles/cmTC_a4b3d.dir/testCCompiler.c.o
FAILED:
C:\Users\JULIUS~1\AppData\Local\Android\Sdk\NDK-BU~1\TOOLCH~1\llvm\prebuilt\WINDOW~1\bin\clang.exe
--target=armv7-none-linux-androideabi --gcc-toolchain="C:/Users/Julius
Debus/AppData/Local/Android/Sdk/ndk-bundle/toolchains/arm-linux-androideabi-4.9/prebuilt/windows-x86_64"
--sysroot="C:/Users/Julius
Debus/AppData/Local/Android/Sdk/ndk-bundle/sysroot" -isystem
C:/Users/Julius
Debus/AppData/Local/Android/Sdk/ndk-bundle/sysroot/usr/include/arm-linux-androideabi
-D__ANDROID_API__=21 -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 -fPIE -o
CMakeFiles/cmTC_a4b3d.dir/testCCompiler.c.o -c "C:\Users\Julius
Debus\Desktop\MyApplication\app.externalNativeBuild\cmake\release\armeabi-v7a\CMakeFiles\CMakeTmp\testCCompiler.c"
Error:Error:error: no such file or directory:
'Debus/AppData/Local/Android/Sdk/ndk-bundle/sysroot/usr/include/arm-linux-androideabi'
ninja: build stopped: subcommand failed.
CMake will not be able to correctly generate this project.
Call Stack (most recent call first):
CMakeLists.txt
-- Configuring incomplete, errors occurred!
See also "C:/Users/Julius Debus/Desktop/MyApplication/app/.externalNativeBuild/cmake/release/armeabi-v7a/CMakeFiles/CMakeOutput.log".
See also "C:/Users/Julius Debus/Desktop/MyApplication/app/.externalNativeBuild/cmake/release/armeabi-v7a/CMakeFiles/CMakeError.log".
Build command failed.
Error while executing process C:\Users\Julius Debus\AppData\Local\Android\Sdk\cmake\3.6.4111459\bin\cmake.exe with arguments {-HC:\Users\Julius Debus\Desktop\MyApplication\app -BC:\Users\Julius Debus\Desktop\MyApplication\app\.externalNativeBuild\cmake\debug\armeabi-v7a -DANDROID_ABI=armeabi-v7a -DANDROID_PLATFORM=android-21 -DCMAKE_LIBRARY_OUTPUT_DIRECTORY=C:\Users\Julius Debus\Desktop\MyApplication\app\build\intermediates\cmake\debug\obj\armeabi-v7a -DCMAKE_BUILD_TYPE=Debug -DANDROID_NDK=C:\Users\Julius Debus\AppData\Local\Android\Sdk\ndk-bundle -DCMAKE_CXX_FLAGS=-std=c++11 -frtti -fexceptions -DCMAKE_TOOLCHAIN_FILE=C:\Users\Julius Debus\AppData\Local\Android\Sdk\ndk-bundle\build\cmake\android.toolchain.cmake -DCMAKE_MAKE_PROGRAM=C:\Users\Julius Debus\AppData\Local\Android\Sdk\cmake\3.6.4111459\bin\ninja.exe -GAndroid Gradle - Ninja}
-- Check for working C compiler: C:/Users/Julius Debus/AppData/Local/Android/Sdk/ndk-bundle/toolchains/llvm/prebuilt/windows-x86_64/bin/clang.exe
-- Check for working C compiler: C:/Users/Julius Debus/AppData/Local/Android/Sdk/ndk-bundle/toolchains/llvm/prebuilt/windows-x86_64/bin/clang.exe -- broken
It fails with the following output:
Change Dir: C:/Users/Julius Debus/Desktop/MyApplication/app/.externalNativeBuild/cmake/debug/armeabi-v7a/CMakeFiles/CMakeTmp
Run Build Command:"C:/Users/Julius
Debus/AppData/Local/Android/Sdk/cmake/3.6.4111459/bin/ninja.exe"
"cmTC_82ebe"
[1/2] Building C object CMakeFiles/cmTC_82ebe.dir/testCCompiler.c.o
FAILED:
C:\Users\JULIUS~1\AppData\Local\Android\Sdk\NDK-BU~1\TOOLCH~1\llvm\prebuilt\WINDOW~1\bin\clang.exe
--target=armv7-none-linux-androideabi --gcc-toolchain="C:/Users/Julius
Debus/AppData/Local/Android/Sdk/ndk-bundle/toolchains/arm-linux-androideabi-4.9/prebuilt/windows-x86_64"
--sysroot="C:/Users/Julius
Debus/AppData/Local/Android/Sdk/ndk-bundle/sysroot" -isystem
C:/Users/Julius
Debus/AppData/Local/Android/Sdk/ndk-bundle/sysroot/usr/include/arm-linux-androideabi
-D__ANDROID_API__=21 -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 -fPIE -o
CMakeFiles/cmTC_82ebe.dir/testCCompiler.c.o -c "C:\Users\Julius
Debus\Desktop\MyApplication\app\.externalNativeBuild\cmake\debug\armeabi-v7a\CMakeFiles\CMakeTmp\testCCompiler.c"
Error:Error:error: no such file or directory:
'Debus/AppData/Local/Android/Sdk/ndk-bundle/sysroot/usr/include/arm-linux-androideabi'
ninja: build stopped: subcommand failed.
CMake will not be able to correctly generate this project.
Call Stack (most recent call first):
CMakeLists.txt
-- Configuring incomplete, errors occurred!
See also "C:/Users/Julius Debus/Desktop/MyApplication/app/.externalNativeBuild/cmake/debug/armeabi-v7a/CMakeFiles/CMakeOutput.log".
See also "C:/Users/Julius Debus/Desktop/MyApplication/app/.externalNativeBuild/cmake/debug/armeabi-v7a/CMakeFiles/CMakeError.log".
C:\Users\Julius Debus\AppData\Local\Android\Sdk\ndk-bundle\build\cmake\android.toolchain.cmake
Warning:Warning:line (63) (include) CMakeLists.txt
Warning:Warning:line (63) (include) CMakeLists.txt
C:\Users\Julius Debus\AppData\Local\Android\Sdk\cmake\3.6.4111459\share\cmake-3.6\Modules\CMakeTestCCompiler.cmake
Error:Error:line (61)/Users/Julius Debus/AppData/Local/Android/Sdk/ndk-bundle/toolchains/llvm/prebuilt/windows-x86_64/bin/clang.exe" is not able to compile a simple test program.
Open File
Error:Error:line (61)/Users/Julius Debus/AppData/Local/Android/Sdk/ndk-bundle/toolchains/llvm/prebuilt/windows-x86_64/bin/clang.exe" is not able to compile a simple test program.
Open File
64 bit Windows 10. Android Studio 2.3.3.
I'm trying to use JNI to link an existing C++ project to Android Studio. I've also tried to load all of the provided NDK-JNI sample projects. Everything with JNI/Cmake is unable to Gradle Sync, failing with the same error:
Build command failed.
Error while executing process C:\Users\Alex\AppData\Local\Android\Sdk\cmake\3.6.3155560\bin\cmake.exe with arguments {-HC:\Users\Alex\Desktop\android-ndk\hello-jni\app\src\main\cpp -BC:\Users\Alex\Desktop\android-ndk\hello-jni\app\.externalNativeBuild\cmake\armDebug\armeabi -GAndroid Gradle - Ninja -DANDROID_ABI=armeabi -DANDROID_NDK=C:\Users\Alex\AppData\Local\Android\Sdk\ndk-bundle -DCMAKE_LIBRARY_OUTPUT_DIRECTORY=C:\Users\Alex\Desktop\android-ndk\hello-jni\app\build\intermediates\cmake\arm\debug\obj\armeabi -DCMAKE_BUILD_TYPE=Debug -DCMAKE_MAKE_PROGRAM=C:\Users\Alex\AppData\Local\Android\Sdk\cmake\3.6.3155560\bin\ninja.exe -DCMAKE_TOOLCHAIN_FILE=C:\Users\Alex\AppData\Local\Android\Sdk\ndk-bundle\build\cmake\android.toolchain.cmake -DANDROID_PLATFORM=android-23 -DANDROID_TOOLCHAIN=clang}
-- Check for working C compiler: C:/Users/Alex/AppData/Local/Android/sdk/ndk-bundle/toolchains/llvm/prebuilt/windows-x86_64/bin/clang.exe
-- Check for working C compiler: C:/Users/Alex/AppData/Local/Android/sdk/ndk-bundle/toolchains/llvm/prebuilt/windows-x86_64/bin/clang.exe -- broken
CMake Error at C:/Users/Alex/AppData/Local/Android/sdk/cmake/3.6.3155560/share/cmake-3.6/Modules/CMakeTestCCompiler.cmake:61 (message):
The C compiler
"C:/Users/Alex/AppData/Local/Android/sdk/ndk-bundle/toolchains/llvm/prebuilt/windows-x86_64/bin/clang.exe"
is not able to compile a simple test program.
It fails with the following output:
Change Dir: C:/Users/Alex/Desktop/android-ndk/hello-jni/app/.externalNativeBuild/cmake/armDebug/armeabi/CMakeFiles/CMakeTmp
Run Build
Command:"C:\Users\Alex\AppData\Local\Android\Sdk\cmake\3.6.3155560\bin\ninja.exe"
"cmTC_accda"
[1/2] Building C object CMakeFiles/cmTC_accda.dir/testCCompiler.c.o
[2/2] Linking C executable cmTC_accda
FAILED: cmd.exe /C "cd . &&
C:\Users\Alex\AppData\Local\Android\sdk\ndk-bundle\toolchains\llvm\prebuilt\windows-x86_64\bin\clang.exe
--target=armv5te-none-linux-androideabi
--gcc-toolchain=C:/Users/Alex/AppData/Local/Android/sdk/ndk-bundle/toolchains/arm-linux-androideabi-4.9/prebuilt/windows-x86_64
--sysroot=C:/Users/Alex/AppData/Local/Android/sdk/ndk-bundle/sysroot
-isystem
C:/Users/Alex/AppData/Local/Android/sdk/ndk-bundle/sysroot/usr/include/arm-linux-androideabi
-D__ANDROID_API__=23 -g -DANDROID -ffunction-sections -funwind-tables
-fstack-protector-strong -no-canonical-prefixes -march=armv5te
-Werror=format-security -Wl,--exclude-libs,libgcc.a --sysroot
C:/Users/Alex/AppData/Local/Android/sdk/ndk-bundle/platforms/android-23/arch-arm64
-Wl,--build-id -Wl,--warn-shared-textrel -Wl,--fatal-warnings
-Wl,--no-undefined -Wl,-z,noexecstack -Qunused-arguments -Wl,-z,relro
-Wl,-z,now -Wl,--gc-sections -Wl,-z,nocopyreloc -pie -fPIE
CMakeFiles/cmTC_f48b1.dir/testCCompiler.c.o -o cmTC_f48b1 -lm && cd ."
The system cannot find the path specified.
ninja: build stopped: subcommand failed.
CMake will not be able to correctly generate this project.
I have all necessary SDK tools installed. I've tried using GCC instead of clang. Thanks for your help!
The main error message is:
The system cannot find the path specified.
Note that above some places use / as path separator:
"C:/Users/Alex/AppData/Local/Android/sdk/ndk-bundle/toolchains/llvm/prebuilt/windows-x86_64/bin/clang.exe"
and have run successfully. And this line:
C:\Users\Alex\AppData\Local\Android\sdk\ndk-bundle\toolchains\llvm\prebuilt\windows-x86_64\bin\clang.exe
Seems to have failed. I guess the problem is the \. Try find where this path is defined, maybe in the IDE options, configuration files or Makefiles, then modify it may solve the problem.
Its because of clang version mismatch
check clang version you have and what minimum clang version Android Application needed!