Search code examples
c++android-studioc++11java-native-interfaceandroid-gradle-plugin

Build release version of shared *.so library with Android Studio


I am making a C++ share library for Android. I created new project with Android Studio and enabled C++.

enter image description here

I also enabled C++ 11 ans Exception support.

enter image description here

New project was created and the build.gradle and CMakeLists.text files were generated. The problem is that Adnroid Studio is only generating a Debug version of the *.so library. I need the release version to be generated too.

The debug library is being generated at

\app\build\intermediates\cmake\debug\obj\\libnative-lib.so

I noticed there is another directory at

\app\build\intermediates\cmake\debug\obj\

but it is empty. It does not have the release version of the library.

How can I force Android Studio to build/compile the release version of the *.so library. I put those images up to make sure that I didn't miss any step.

Using Android Studio 2.3.


Solution

  • Played around with Android Studio and discovered that this can be changed by selecting the Root of your project (app) going to Build --> Select Build Variant... then change the Build Variant from Debug to Release.

    enter image description here