FAQ: Resolving libc++_shared.so conflicts

Problem description

Your project depends on libc++_shared.so, which conflicts with the libc++_shared.so in the RC SDK during compilation.

Error stack trace:

2 files found with path 'lib/arm64-v8a/libc++_shared.so' from inputs: 
 - /{path1}/jni/arm64-v8a/libc++_shared.so  
 - /{path2}/transformed/jetified-im_libcore-5.x.x/jni/arm64-v8a/libc++_shared.so

path1 and path2 indicate the conflicting paths, caused by both your project and the RC SDK including libc++_shared.so.

Solution

Solution 1
  1. Remove libc++_shared.so from your project.

  2. Add this code to build.gradle to deduplicate:

       packagingOptions {
            pickFirst('lib/armeabi-v7a/libc++_shared.so')
            pickFirst('lib/arm64-v8a/libc++_shared.so')
            pickFirst('lib/x86/libc++_shared.so')
            pickFirst('lib/x86_64/libc++_shared.so')
        }
    
Solution 2 (SDK version ≥ 5.6.1)

If the libc++_shared.so in the RC SDK doesn’t meet your project’s requirements and must be excluded, use this solution.

When adding the RC SDK dependency, exclude libc++_shared.so like this:

implementation ("cn.rongcloud.sdk:im_lib:x.y.z")  { 
 exclude group: 'cn.rongcloud.sdk', module: 'cpp_shared'
}

// Skip this if you’re not using the Kit SDK
implementation ("cn.rongcloud.sdk:im_kit:x.y.z")  { 
 exclude group: 'cn.rongcloud.sdk', module: 'cpp_shared'
}

More support

If you have questions, feel free to submit a ticket.