I have a Java Android application project that includes a so library in libs/armeabi folder.
The c++ code of this library is in a different Android NDK project and is dependent on other different library NDK projects.
Is it possible to debug the c++ code of this library while the Java Android application is running?
In order to debug the native code in .so, first you need .so that was generated with debugging mode. (e.g., NDK_DEBUG = 1)
If you don't have source code and therefore no debuggable .so, there is no way to debug.
Also, please specify your environment such as Android NDK version, IDE, etc.
Assuming you are using Eclipse, this is detailed description how to debug native applications.
Related
I am building an open source lib C/C++ for Android development using Android NDK. I had got code from Github and created my own jni folder under source code. In that jni folder, I created some C source files and included many header files in open source lib. But when I built, I had got failed log:
fatal error: bits/libc-header-start.h: No such file or directory
I checked and saw that file "libc-header-start.h" existed in /usr/include/x86_64-linux-gnu/bits/ folder of Ubuntu system but when building, it can not link to that header file
So can I use Ubuntu system header file in my Android NDK lib?
No, you should not use Ubuntu (or any other host) includes or libs to build an Android NDK library. NDK cross-compiles your code for the Android targets. Not all C++ projects on GitHub may be ported easily to Android. If they use CMake, these scripts often need adaptations for Android NDK. If they use automake tools, tuning the build scripts may be quite painful.
So can I use Ubuntu system header file in my Android NDK lib?
NO. You have to use all the Android NDK specific headers and libs for your NDK compilation, i.e. those inside your NDK folders.
Here is an example for Android JNI programming: https://github.com/russell-shizhen/JniExample
I am trying to build a .so for android and I want to build with address sanitizer but the only instructions I see are for Android NDK based Makefiles, but I am using the newer endorsed CMake setup. Just adding the flag -fsanitize=address wasn't enough as the clang runtime library was missing.
what is the correct thing to add in my CMakeLists for Android built libraries?
You also need to prepare your device as described in documentation. You have to run asan_device_setup script from NDK. It will put asan .so on the device.
First step: I use QtCreator to compile a bunch of libraries (.so files) + a GUI test program to test those libraries on an Android device.
Second step: After I tested them, I re-compile the libraries without the GUI test program and send them to a client who's going to integrate those .so file in its own Andoid application (generating and apk), not using QtCreator anymore. I do this step using QtCreator (because it's setup, very easy for me to just remove the GUI test program and hit compile), but I'm pretty sure they could also be compiled directly using ndk-build if I work on writting the correct make files for that.
When I re-compile the libraries, there's still a "Android build SDK" option under "Build Android APK" set to "android-22" in QtCreator. However, my client generates its final app for "android-19". And we are wondering if this could be a problem.
My understanding is that my .so files generated in "second step" are built using the NDK only (SDK is not used, so android API version "android-22" is irrelevant as I do not generate any APK...). So there should be no compatibility issue when those .so files are integrated in an application, as far as the same NDK version is used.
Am I right?
I am using the following:
Android Studio 2.2.2
Android Gradle Plugin 2.2.2
NDK r12b, r13
externalNativeBuild (ndkBuild and cmake)
I have a native JNI .so that statically links roughly two dozen other libraries. The native library exposes a Java API that is, of course, bound to the JNI. I have successfully built this library using both ndkBuild and cmake, as well as both NDK r12b and r13.
I have a test harness project that builds both an Android app module and this native library module.
According to the Android Studio 2.2 docs, using the combination of Android Studio 2.2.2, Gradle 2.2.2 and the new externalNativeBuild mechanism, native debugging is suppose to "just work." I have found, however, that native debugging only works when I set the Build Variant of the library module to "release".
I would expect a release build to be packaged with the debug symbols stripped out, so I am extremely confused. Has anyone else seen this behavior? I don't want to have to use a release variant for debugging, it makes no sense...
hi how to build ndk application...now i am using linux os and i am new for android application please tell me simply....
This should hopefully help you out:
http://www.jondev.net/articles/Using_NDK_r4_with_the_Android_SDK_in_Netbeans
Shows you how to build a simple 'Hello World' app using the NDK.
Be aware that the NDK will not let you build applications. It will only let you build a shared library object (.so) that your SDK application will open at runtime in order to execute native code.
Instead of the standard way to build and install applications:
ant compile # (or ant debug)
ant install
You will have an extra step:
ndk-build # builds the .so files
ant compile # builds the Java app and embeds the .so within the final .apk
ant install