in firebase crashlytics we see no stacktrace for native crash
How do we include symbol files?
Below is my guess on how to proceed..
build NDK from source and generate *.so files. They are typically generated under obj or libs folder.
find the path of the *.so files
direct crashlytics to upload those symbols using firebaseCrashlytics directive in build.gradle (https://firebase.google.com/docs/crashlytics/ndk-reports)
I'm not sure if my assumption is correct, if it is.. How do I do #1? build NDK?
I can see that react-native can generate those *.so files when I build react-native from source files. (such as libc++_shared.so)
I guess we need to do the same thing as RN is doing.
Related
I'm struggling with an issue compiling VLCLib. I successfully compiled it, generating the .aar file that I can include in my project. But I can only do that for one Android ABI that I specified in my ~/.bashrc file.
According to the documentation, run the script compile.sh, and it will generate binaries and an .aar file for the declared architecture in the bashrc variable. But if I change it and run compile.sh again it removes previously generated binaries and only keeps the new architecture. Is there a way to generate a multi architecture that I can use in armeabi-v7a and also in x86? So I don't have to release an platform-specific APK of my project?
Follow this document for VLC Libs.
I trying to build android application with some precompiled native libraries:
liba.so and libb.so.1.2.3
Libraries are placed into jniLibs subdirectory.
After building APK file, only liba.so included into it, but not libb.so.1.2.3.
Result is predictable. Application crashes at start.
What to do with build scripts to include all files from jniLibs into APK?
Due to the native library regex ^.+\\.so$ being used in the Android Gradle plugin, it is impossible to include anything other than .so files using the jniLibs folder. And even if you were to somehow add the library to the APK, the dynamic loader on Android is very limited and will most likely not be able to load them.
Your best bet is to remove the version altogether by renaming the library and changing its internal soname before linking against it.
Unfortunately I don't develop for Android anymore, so I can't test this, but I know Gradle and this might work for you. Looking at the Android DSL docs, you might be able to change the filtering on the jniLibs folder:
android {
sourceSets {
main {
jniLibs.filter.include("**/*")
}
}
}
Let me know if this works!
Just add the jniLibs folder in app/src/main and it will include the .so file in the apk.
/app/src/main/armeabi/*.so files
Android Studio 2.2 introduces cmake external build system. The problem is that documentation is really lacking and I do not know how should I link third party libraries? I've tried cmake directive target_link_libraries:
target_link_libraries(native-lib libs/libSomething.so)
And it "works" in that app compiles but then I get dlopen error at runtime because libSomething.so has not been packaged with application. The libs directory is under "app" if that changes anything and I've started with default JNI project generated by Android Studio 2.2...
[Update]
I've tried putting libSomething.so under app/src/main/jniLibs/armeabi-v7a but now the "main" (native-lib) library is not packaged.
[Update2]
I've added source set config that includes cmake output dir and this works but is ugly as hell and is not really a permanent solution...
sourceSet
{
main
{
jniLibs.srcDirs = [ "libs", ".externalNativeBuild/cmake/debug/obj"]
}
}
For now I ended up copying libSomething.so to cmake library output directory in a post build step. This works because it turns out that Android Studio copies into apk EVERYTHING that is in that directory.
Command in cmake is the following:
add_custom_command(TARGET native-lib POST_BUILD
COMMAND ${CMAKE_COMMAND} -E copy
${CMAKE_CURRENT_SOURCE_DIR}/libs/${ANDROID_ABI}/libSomething.so
${CMAKE_LIBRARY_OUTPUT_DIRECTORY}/libSomething.so
)
For now, you could also put your shared libs into directory, and configure jniLibs to point to that directory, that will pack it. One sample is here: https://github.com/googlesamples/android-ndk/tree/master/hello-libs, follow gperf see if that helps. This way app not depending on the generated build folders. When android studio added packing libs, the jniLibs workaround is not necessary anymore
I Have an application that uses a shared jar library located on my platform. I would like to build my project off my platform. To do so, I need to include the jar file in compilation.
This works in Eclipse - I add the library to the project, and everything works fine. I encounter a problem after building with ant. Ant requires that I include the jar file in my libs directory. However if I include it there, it is exported into the apk. When I deploy this locally built apk to my device, I get runtime errors complaining about multiple symbol definitions.
Try to add a custom_rules.xml file to your project to exclude jar after compilation from apk. See here Exclude dependency jar file from apk when using Ant for Android
I've made an android library project that uses some native libraries.
I've made the jni wrapper and put the native libs (.so) in the libs// folders. The native libs are compiled using cmake, for armeabi, armeabi-v7a, x86 and mips.
I export this project to a jar and put this jar into a "normal" android project. I then export this project to an apk and can see that my libs are bundles into it.
However, when i install the apk, the libs corresponding to the device are not copied into /data/data/com.my.app/lib and obviously, running the app complains about not finding the libs (UnsatisfiedLinkError).
I've search through SO and everywhere i can but found no answer that solved my case.
i'm using Eclipse, btw
Thanks for your help
UPDATE
OK, i've read the doc in the ndk and seen the examples, and unfortunately, i can't see the solution.
The ndk build the c code into shared libs and places them into the appropriated location in the project. But it doesn't generate anything that says that the libs must be installed with the apk.
My goal is to provide an android library (so a jar), that can be included within an android application. I don't see the real difference between what i'm doing (compile the c libs using cmake and package the jni and java compiled classes into a jar) and what is done with android.mk
If you see what i'm missing, feel free to tell me (even if its obvious).
thanks
UPDATE
i've made a dirty hack: in the libs folder of my application, i've put the jar file containing my classes and my native libs and a copy of the .so files for each arch. Suprise, the libs are no installed in /data/data/com.me.myapp/lib
It seems to confirm that it's a packaging problem.
I export this project to a jar and put this jar into a "normal"
android project. I then export this project to an apk and can see that
my libs are bundles into it.
The issue is that the Android packaging system doesn't handle with binary assets in JARs. For your application project to find and include the generated .so files, you need it to reference the library project as an 'Android library project':
Did you call ndk-build command?
See description below for details.
http://developer.android.com/tools/sdk/ndk/index.html
You can build the shared libraries for the sample apps by going into /samples// then calling the ndk-build command. The generated shared libraries will be located under /samples//libs/armeabi/ for (ARMv5TE machine code) and/or /samples//libs/armeabi-v7a/ for (ARMv7 machine code).