Crashlytics NDK multi androidNdkOut path support

2019-05-14 09:23发布

问题:

I use Fabric Crashlytic to impove my native code performance. I have multi .so library in both app project and jar library project. In my app's build.gradle,here it is:

crashlytics {
    enableNdk true
    androidNdkOut '<myJarProjectPath>/src/main/obj' //or src/main/obj
    androidNdkLibsOut '<myJarProjectPath>/src/main/jniLibs' //or src/main/jniLibs
}

then I use "crashlyticsUploadSymbolsXXXXRelease" to package my app,and get ndk crash stacktrace in Fabric. But I can only config one of these .so library. I wonder if use "crashlyticsUploadSymbolsXXXXRelease" to get an Apk, what will happen to .so in jar library project? Does anyone know how to support ndk crashlytics both in app project and jar library project?

回答1:

Matt from Crashlytics here!

UPDATE

As of version 1.23.0, the Fabric plugin supports automatic detection of paths for native binaries when using the Android plugin for Gradle 2.2.0+ with the externalNativeBuild DSL. If using this, you should simply remove the androidNdkOut and androidNdkLibsOut properties from your crashlytics block.


Currently we don't have support for defining multiple directories for your native libraries. However, a very simple workaround for this is to define a Gradle task which copies your debug and release .so files from both projects into a common, temporary directory (e.g. temp/ndkout/... and temp/ndklibsout/) and then set your androidNdkOut and androidNdkLibsOut properties to those directories.

One thing to note: you'll need to maintain the architecture-specific folder structure under each set of directories! Here's a full example to give you an idea:

temp/
-- ndkout/
  -- armeabi
    -- libappproject.so
    -- libjarproject.so
  -- x86
    -- libappproject.so
    -- libjarproject.so
  ...
-- ndklibsout/
  -- armeabi
    -- libappproject.so
    -- libjarproject.so
  -- x86
    -- libappproject.so
    -- libjarproject.so
  ...