How to prevent my JNI folder from rebuilding?

Issue

Anytime I clear build folder in flutter (either with flutter clean or manually), my jni folder rebuilds (~40 mins). Is that possible to compile library to some binary, and use it from android without breaking any interfaces and functionality?

P.S. My library consists of many folders and contains .mk, .c, .cpp, .h files.

Solution

Is that possible to compile library to some binary, and use it from android without breaking any interfaces and functionality?

Of course yes. Build you libraries like shared .so or static .a and use them like prebuilts. Here the example how to use native prebuilt libraries: How to link .a to .so and create new .so for android

Moreover, you can also put them together with the used SDK, NDK, AS, and other thirdparties in Docker image and work with your project from Docker.

Answered By – Mykola Khyliuk

Leave a Comment