We're developing an Android library with native part. We're mostly Java developers, not C++. Our tiny C++ experience was enough to write the native code we need but we've encountered unexpected troubles with stripping (which doesn't related to programming directly). Due to some reasons we do need the output native library (xxx.so file) stripped. The problem is it's hard to find info how to do this in our particular case. There are a lot of results in Google but we don't' understand how to apply them. The most popular answer is "just check the related checkbox in your IDE". Hmm, what checkbox? We tried to set Jni Debuggable
checkbox to true in config (it looks relevant) - no effect. We added -s flag (as suggested in many answers) as follows:
defaultConfig {
..
externalNativeBuild {
cmake {
cppFlags "-fexceptions -s"
abiFilters 'armeabi', 'x86'
}
}
}
No effect. We added the same flag according to this answer like the following:
set(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} -s")
set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -s")
set(CMAKE_C_FLAGS_RELEASE "${CMAKE_C_FLAGS_RELEASE} -s")
set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -s")
No effect again! Finally we tried the straightforward variant to apply strip utility to our output library manually (as many guys suggested). The problem is the utility says Unable to recognize the format of the input file 'xxx.so'. Weird... Our C++ developers (not for Android) couldn't help us, they "just check the related checkbox in IDE". We're absolutely sure it shouldn't be difficult but spent a lot of time for this task and read tons of pages without result.
@anton-malyshev is right! I used elfedit and objdump from the same package before and they worked well with the same file that confused me. I applied appropriate strip from NDK, now it works without errors but do nothing though. I used
strip -s -v xxx.so
syntax, this shows message copy from 'xxx.so' [elf32-littlearm] to 'sta10988' [elf32-littlearm], but xxx.so file stays unchanged. What is sta10988? A temp file? If my understanding is correct then the utility should reduce library size since it contains many symbols (according to elfedit and objdump). I tried to apply other options for strip (like -I -O) but didn't manage to get any working combination. Sorry, I'm not a fan of console apps. How to use this utility correctly?