简体   繁体   中英

How to create a standalone library for Android using NDK?

I know this will likely come as a question that could have been answered by joining information from different previous questions, but I sincerely could not come up with anything. As a neophyte in building Android projects, I'd like to build:

  • An Android library (to be futurely imported by applications) capable of using components such as Bluetooth and Networking
  • It requires a static C library I wrote (which should, I think, be used through NDK)
  • It should be easily distributable (not rely on master projects or on excessively complex build settings)
  • There should be some sort of app test project associated to it as some sort of subproject to, well, test the library
  • I'd prefer to build it using command-line Gradle, but I'd accept using Android Studio as well.

How would I go around setting up this project?

  1. NDK is just for android library, please follow normal guide, nothing is special. Using socket is ok, if you mean it the "Networking". Using BT is not possible in native, but you can call Android BT API via JNI
  2. you need the c source rather than static library, because NDK will build for multiple arch(arm/armeabi/x86/mips)
  3. yes you can send the built so files to others, no problem
  4. Nothing is special for testing. write a Java app and test library via JNI, or makeup a pure native app and call the library directly.
  5. Android Studio using Gradle for build script. you can build in command line, or in Android Studio, no problem

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