简体   繁体   中英

How to publish Kotlin + JNI android library to Bintray?

I've been developing a library to use in my project, and while it is working locally, I would like to share it and use it as an external dependency.

How do I wrap my library so that built AAR contains both *.so native library and generated *.java classes (generated by Kotlin compiler) ? Because there are two-way interactions in my library: Kotlin external functions defined in C++, and some C++ code calling Kotlin classes and methods.

So, my questions are:

  • How to correctly package Kotlin + JNI android library ?
  • How to upload said package to Bintray so users (and myself) could use it as a dependency ?

(Note: I've seen tutorials and examples, but they were either Kotlin/Android or Java/Jni/Android)

If you want to package .so with your application, note that you can always put it inside JAR file. Then, you can unpack it, and load it using System.load .

You can find sample here: https://github.com/mkowsiak/jnicookbook/tree/master/recipes/recipeNo031

Note

Remember that packaging .so inside application is a risky thing. As you deal with native code, you have to be 100% sure that all native dependencies are there. You have to pay attention to architecture as well.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM