1
votes

We were using Android.mk & Application.mk NDK builds system. As we have common modules in the native layer which are being used by multiple projects, as the other projects are already supporting CMakeLists.txt, we are moving our Android project as well to CMake.

I have multiple static libraries in the sub-directories and the main directory (jni/) is generating the SO file. I have written CMakeLists.txt individually in the sub-directories and included them (add_subdirectory) in the jni/CmakeLists.txt file.
I see compilation is going through but not able to find the .so files either in build/intermediates/cmake/release/obj/armeabi or project/libs folder. But I see the below message int he Android Studio Gralde

Excerpt from the below:

-soname,liblogger.so -o /home/suman//build/intermediates/cmake/release/obj/armeabi-v7a/liblogger.so Logger/CMakeFiles/logger.dir/src/Logger.cpp.o

Full Command:

[2/2] : && /home/suman/Android/android-ndk/toolchains/llvm/prebuilt/linux-x86_64/bin/clang++ --target=armv7-none-linux-androideabi --gcc-toolchain=/home/suman/Android/android-ndk/toolchains/arm-linux-androideabi-4.9/prebuilt/linux-x86_64 --sysroot=/home/suman/Android/android-ndk/sysroot -fPIC -isystem /home/suman/Android/android-ndk/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 -marm -Wa,--noexecstack -Wformat -Werror=format-security -frtti -fexceptions -fvisibility=hidden -fstack-protector-all -Wall -c -fmessage-length=0 -Os -DNDEBUG
-Wl,--exclude-libs,libgcc.a -Wl,--exclude-libs,libatomic.a --sysroot /home/suman/Android/android-ndk/platforms/android-21/arch-arm -Wl,--build-id -Wl,--warn-shared-textrel -Wl,--fatal-warnings -Wl,--fix-cortex-a8 -Wl,--no-undefined -Wl,-z,noexecstack -Qunused-arguments -Wl,-z,relro -Wl,-z,now -shared -Wl,-soname,liblogger.so -o /home/suman//build/intermediates/cmake/release/obj/armeabi-v7a/liblogger.so Logger/CMakeFiles/logger.dir/src/Logger.cpp.o /home/suman/Android/android-ndk/platforms/android-21/arch-arm/usr/lib/liblog.so -latomic -lm "/home/suman/Android/android-ndk/sources/cxx-stl/gnu-libstdc++/4.9/libs/armeabi-v7a/libsupc++.a" "/home/suman/Android/android-ndk/sources/cxx-stl/gnu-libstdc++/4.9/libs/armeabi-v7a/libgnustl_shared.so" && :

Am I missing anything?

My folder structure is old Android build folder structure (Eclipse Folder Structure) - Flat structure. As project is pretty old and huge, didn't got migrated to new folder structure instead we are specifying the sourceSets in the build.gradle file.

1
Got the issue fixed. I was setting some CMake variables before declaring the project(), due to which those settings were taking effect only in that file. It was not propagating to the the included_directories() and add_dependencies().Suman

1 Answers

0
votes

1) Got the issue fixed. I was setting some CMake variables before declaring the project(), due to which those settings were taking effect only in that file. It was not propagating to the the included_directories() and add_dependencies().

2) Don't declare any externalCMakeBuild { cppFlags } in the build.gradle file. It was messing up with NDK flags set by the build system.