kezong / fat-aar-android

A gradle plugin that merge dependencies into the final aar file works with AGP 3.+
MIT License
3.08k stars 607 forks source link

Duplicated *.so resources #400

Open kannabi opened 1 year ago

kannabi commented 1 year ago

Describe the issue I have a problem with native lib merge. I have two modules: opencv and another one that use opencv. image I connect opencv dependencies by cmake at second module like this

include_directories(${OpenCV_DIR}/native/jni/include)
add_library(lib_opencv SHARED IMPORTED)
set_target_properties(lib_opencv PROPERTIES IMPORTED_LOCATION ${OpenCV_DIR}/native/libs/${ANDROID_ABI}/libopencv_java4.so)

target_link_libraries(nativelib lib_opencv log)

Where nativelib is current module lib

How can I merge this two dependencies?

Build Environment

zhanlan123 commented 1 year ago

请在build.gradle中使用下面类似的代码排除

packagingOptions {
        pickFirst 'lib/x86/libc++_shared.so'
        pickFirst 'lib/armeabi-v7a/libc++_shared.so'
        pickFirst 'lib/arm64-v8a/libc++_shared.so'
        pickFirst 'lib/x86_64/libc++_shared.so'
}
kllkko commented 1 year ago

没有作用

zj8331182 commented 1 year ago

anyone fix this issue? i have the same problem

lucifer-kave commented 1 year ago

这个有办法解决吗?

lucifer-kave commented 1 year ago

我这边的解决方案是: 在打包的时候把冲突的库先exclude,然后在compileOnly添加进来。看起来是能用,但是不确定对所有情况都适用。 embed("abcde:gfh:0.1") { transitive = false exclude group: "111111", module: "22222" exclude group: "3333", module: "4444" } compileOnly("111111:22222:0.2") compileOnly("3333:4444:0.2")