Managing .so Libraries: Best Practices for Seamless Integration

Payal Rajput
Simform Engineering
5 min readMay 19, 2023

Shared libraries play a crucial role in the functioning of multiple applications. They streamline efficiency by eliminating duplicate library files and provide a native path for Java Native Interface (JNI) libraries.

When it comes to managing .so libraries, it becomes paramount to ensure a seamless integration that enables your application to function flawlessly in real-time scenarios.

In this blog, we will explore invaluable tips and guidelines for effectively managing .so libraries and insights into addressing potential issues that may arise during the Play Store publishing process.

Choosing the Right .so Libraries

Determining the appropriate .so libraries to include in your application is vital. These libraries contain native code that enables specific functions within your app. To make informed decisions, it is essential to consult the documentation of any third-party libraries you utilize and verify their compatibility with your target platforms.

Here are some popular libraries widely used in app development:
1) SQLite: A powerful library renowned for efficient database management in apps.
2) OpenAL: An audio processing library that finds utility in numerous games and other apps.
3) Glide Transformations: An Android transformation library providing a variety of image transformations for seamless integration with Glide.

To ensure proper integration, make sure to include .so library files in your project’s /src/main/jniLibs/ directory.

Verifying Library Compatibility and Packaging

To avoid compatibility issues and ensure optimal performance,

  • Ensure that in your project’s build.gradle file, the Android Gradle plugin is set to “ndk”; specify the different CPU architectures your app will support, such as ARM, ARM64, x86, and x86_64.
  • Use the ‘file’ command in the terminal to check the architecture of your .so files. For example, if you have a file called libexample.so, you can run ‘file libexample.so’ in the terminal to see the architecture.
  • Inspect the APK file generated by your build process to ensure the .so libraries are packaged with your app.
  • Make sure to use the latest version of the .so libraries to avoid compatibility issues. Regularly check for updates and replace the outdated .so libraries with new ones.
  • Before publishing your app on the Play Store, perform rigorous testing to identify and resolve any issues related to .so library integration.
  • Fine-tune your app’s performance by utilizing 32-bit and 64-bit libraries to ensure it runs smoothly on different devices.

Supporting 32-bit and 64-bit Architectures

If you have developed your app solely in Java or Kotlin, you don’t need to worry about the device used for downloading. But, if you’ve added native code, ensure it can work on both 32-bit and 64-bit devices.

  • To check for 64-bit libraries, examine the structure of your APK file. The APK includes necessary native libraries in various folders based on the ABI (Application Binary Interface). While you don’t need to support every 64-bit architecture, you must include the corresponding 64-bit architecture for each native 32-bit architecture you support.
  • For the ARM architecture, the 32-bit libraries are located in armeabi-v7a folder. The 64-bit equivalent is placed in arm64-v8a folder.
  • For the x86 architecture, 32-bit libraries reside in x86 and 64-bit in x86_64 folder.

Note: Ensure that you have native libraries in both 32-bit and 64-bit architecture folders. For more detailed information, refer to the document provided here.

Building 64-bit Libraries

To build 64-bit libraries, follow these instructions:

Configure Android Studio and Gradle

Android Studio, a powerful software for Android development, utilizes Gradle as its build tool. To ensure compatibility with different devices, make some modifications to your app’s ‘build.gradle’ file. This code specifies the types of devices your app should work on. Simply add “arm64-v8a” and/or “x86_64” to the file:

The ‘ndk.abiFilters’ controls the ABIs (Application Binary Interfaces) the Android Gradle plugin should build and package native libraries for. When the flag is not configured, Gradle builds and packages all available ABIs.

For more detailed instructions, refer to the documentation provided here.

Resolving Play Store Publish Issues

To tackle real-time scenarios like play store issues, here are the steps you can follow:

  • Check the Google Play Console for any error messages or warnings that may prevent your app's publication. Resolve any identified issues. For example:
  • Ensure that your app complies with the Google Play Developer Program Policies. If your app violates any of the policies, it will not be allowed to be published on the Play Store.
  • If your app is rejected due to issues with .so libraries, verify that they are correctly included and compatible with the architectures specified in your app’s build.gradle file.
  • Ensure that your app includes all the necessary libraries for the target devices. Use the “Supported devices” feature in the Play Console to specify the supported devices and required architectures.
  • If you are unable to fix the issue, reach out to Google Play Support for assistance. They can provide detailed guidance on resolving the issue and help you successfully publish your app on the Play Store.

By following these tips and guidelines, you can manage .so libraries and ensure your application works perfectly fine in real-time scenarios. Remember to prioritize testing and performance optimization, using native libraries only when necessary and regularly updating outdated versions.

If you’re eager to dive deeper into generating 32-bit and 64-bit libs, let us know!

Stay connected with Simform Engineering for more exciting and informative content.

Thank you for reading. Happy coding :)

Follow us: Twitter | LinkedIn

--

--

Payal Rajput
Simform Engineering

Sr. Android Developer @Simform. Committed to viable and easily functional app solution. #Android #Kotlin #Java