8

My question is similar to the one asked here:

How to Exclude Duplicate C Shared Libraries (.so) in a Multi-Project Android Build?

In my project, I have a shared library which has some native code MySharedLib . I have an app TestDuplicateSharedLibApp which depends on MySharedLib and also has native code.

As part of the gradle build, I disable automatic call to ndk-build by setting jni.srcDirs =[]. I explicitly call ndk-build command.

As part of the MySharedLib build process, libMySharedLib.so is generaed and packaged in to MySharedLib.aar.

TestDuplicateSharedLibApp depends on MySharedLib. As part of the ndk-build, libTestDuplicateSharedLibApp.so and libMySharedLib.so are copied to the TestDuplicateSharedLibApp/libs directory.

Since I need to package shared libraries in the final apk, I have jniLibs.srcDirs=['libs'] in my build.gradle.

When the final apk is being packaged, the packaging fails due to duplicate copies of libMyShared.so , one from MySharedLib.aar and other from TestDuplicateSharedLibApp/libs . I tried pick-first and exclude packaging options, but they didn't help.

Basically what I need is an equivalent of jniLibs.srcDirs for files. In TestDuplicateSharedLibApp I would like to say: Only include libTestDuplicateSharedLibApp.so. I envision this by doing: jniLibs.srcDirs=[] and, if there exists a jniLibs.srcFiles option jniLibs.srcFiles='libTestDuplicateSharedLibApp.so'

I would appreciate insights in solving this problem.

Community
  • 1
  • 1
pka
  • 351
  • 4
  • 8

0 Answers0