java - Android native library linking against another native library from aar -


i have curious question. have aar library, contains , uses native .so library. now, want write lib, depends on library , has native part depending on native lib first lib. dependent library uses both native code , java wrappers first lib.

i wonder, there way, how standard gradle dependency(with copied headers files first lib)? or have build second lib directly sources?

why need this: have multiplatform lib basic functionality, android aar. lib can used in standard android app , use in multiple projects, have no native code.

but in 1 app want write multiplatform shared app code, depending on lib , want have these libs separated.

thanks!

here workable example basic on opencv, can same first lib.

prepare first lib following

package jar, *.so, , exported headers (see file opencv4android/opencv/build.gradle in linked project how append headers aar).

you first.aar example building of first lib.

using first lib in other projects

add first.aar in other projects when needed.

allprojects {     repositories {         jcenter()          flatdir {             dirs '/path/to/aar'         }     } }  // in app's build.gradle dependencies {     // ...     compile 'com.example:example-with-header@aar'     // ... } 

link against native library first.aar native build system.

if use cmake, should this

add_library(first shared imported)  set_target_properties( first properties imported_location ../../../../build/intermediates/exploded-aar/org.example/example-debug/jni/${android_abi}/libfirst.so # use find command figure out location of first lib before use it, not sure if it's different in different build environment # android studio gradle plugin latest version use # ../../../../build/intermediates/transforms/mergejnilibs/debug/folders/2000/1f/main/lib/${android_abi}/libfirst.so )  # use find command figure actual location of exported header aar # might different in environment different version of gradle plugin include_directories(build/intermediates/exploded-aar/com.example/example-debug/cpp/include)  target_link_libraries( # specifies target library.                        native-lib                         # links target library log library                        # included in ndk.                        first                        ${log-lib} ) 

Comments

Popular posts from this blog

python - pip install -U PySide error -

arrays - C++ error: a brace-enclosed initializer is not allowed here before ‘{’ token -

cytoscape.js - How to add nodes to Dagre layout with Cytoscape -