Issue
I'm trying to add Crashlytics support to my Android project, which uses NDK and gradle CMake. This means that I need symbols for my shared projects. So if I want to create the symbols for release build I'll call gradlew crashlyticsUploadSymbolsRelease
The official document in https://docs.fabric.io/android/crashlytics/ndk.html says that The symbol generation and upload process assumes a standard project structure: src/main/obj for debug binaries, and src/main/libs for release binaries as produced by ndk-build.
In the gradle file this means a new block which is like the following:
crashlytics {
enableNdk true
androidNdkOut 'src/main/obj'
androidNdkLibsOut 'src/main/libs'
}
Because I am using the gradle CMake integration to build my native libs, the default paths of course are not working. My native libraries in release mode are built into a build/intermediates/cmake/release/obj
directory and in debug mode they go to build/intermediates/cmake/debug/obj
directory.
From trial and error I figured that if I want my release build to work, I'll have to put the path to release mode native libraries into both lines, as illustrated below.
crashlytics {
enableNdk true
androidNdkOut 'build/intermediates/cmake/release/obj'
androidNdkLibsOut 'build/intermediates/cmake/release/obj'
}
I just really don't understand the difference between androidNdkOut
and androidNdkLibsOut
variables, because at least in my scenario they point to same directory. Fortunately this isn't a problem for me because I just need Crashlytics to work with my release binaries.
So my questions are:
1) What is really the difference between androidNdkOut
and androidNdkLibsOut
? Why I cannot put a path to my debug binaries in one and path to release binaries to other? A concrete example would be nice in addition to explanation.
2) How should I modify my gradle file if some day I want to include symbols for my debug libraries as well? Meaning that the command
gradlew crashlyticsUploadSymbolsRelease
as well as gradlew crashlyticsUploadSymbolsDebug
would work?
There is a discussion about this in the threads Crashlytics NDK symbols and Gradle tasks and Crashlytics NDK multi androidNdkOut path support but they really don't answer to these two questions.
Solution
I work on the Fabric team that maintains our Crashlytics NDK support.
To give some context - our symbol upload tool is based on the ndk-build
process which produces 2 sets of binaries: your production binaries, which are stripped of symbol data, and debug binaries, which have symbol data intact for debugging purposes.
The Gradle properties map to variables in the ndk-build
process, specifically:
androidNdkOut
is the directory under which the unstripped, debug binaries are placed (equivalent to the$NDK_OUT
variable inndk-build
) calledobj
by default.androidNdkLibsOut
is the directory under which the stripped, release binaries are placed (equivalent to the$NDK_LIBS_OUT
variable inndk-build
) calledlibs
by default.
The expected contents of these paths are the architecture-specific directories for your libraries, so for example:
obj/
— armeabi
— lib1.so
— lib2.so
— x86
— lib1.so
— lib2.so
libs/
— armeabi
— lib1.so
— lib2.so
— x86
— lib1.so
— lib2.so
All you’ll need to do for our symbol upload to work is to generate these same sets of binaries from CMake, and then set your androidNdkOut
and androidNdkLibsOut
to the appropriate top-level directories where those libraries can be found.
EDIT/UPDATE July 7, 2017
We've just released version 1.23.0 of the Fabric plugin for Gradle which supports automatically resolving the appropriate native library paths when you're using the Android Gradle plugin 2.2.0+ with the externalNativeBuild
DSL, so you no longer have to set androidNdkOut
and androidNdkLibsOut
if you're using the latest Android Gradle plugin. Check out more info here: https://docs.fabric.io/android/crashlytics/ndk.html#specifying-the-path-to-debug-and-release-binaries
Answered By - mWillis
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.