Many friends in the development of the Android JNI, will encounter Findlibrary returned null error, for some reason, so is not packaged into the APK. The following is an analysis of the cause of the error and platform compatibility issues.
First, there is no reason to pack so into the APK.
When you find findlibrary returned null error, the most straightforward solution is to unzip the APK to see if there is a corresponding so in the x86, Armeabi, and armeabi-v7a folders in the APK. At this point you may find less so in the corresponding folder, and then check the reason.
There are generally two reasons for this:
There is a folder for the corresponding platform in 1.apk, but there is no corresponding so in the folder.
For example, when the x86 folder appears under Lib in the APK, the program will load the x86 corresponding library when it runs, but if the x86 folder does not come in at this time, an error will be encountered.
2. Third-party compatibility policies with the platform are inconsistent with their own.
It is possible that a third party has chosen to support only Armeabi (assuming a payment SDK), but our game is configured in application.mk with App_abi: = All, and so, our game is packaged with so on all platforms, But the third party only Armeabi folder corresponding so, causing the program to run abnormally, this situation in the development of the most common, some small companies due to insufficient testing personnel or testing equipment, after the online only to find this problem is not surprising.
Second, for the platform support, we should choose how.
ARMEABI-V7A really can be compatible with Armeabi, and v7a CPU support hardware floating point arithmetic, the current large logarithmic device is already v7a, so in order to better performance, do not put to Armeabi for compatibility. x86 is compatible with the Armeabi platform, whether armeabi-v7a or Armeabi, but also the performance of the loss, in addition, it should be pointed out, packaging out the x86 so, will always be smaller than the volume of Armeabi platform, for the performance of the children's shoes neat cleanliness, It is recommended to support x86 when packing so. Specifically, the performance loss, the author is not very clear, you can visit the official Intel in the CSDN blog. A summary of the performance in the project is:
If the project contains only Armeabi, it can be run on all Android devices; If the project contains only armeabi-v7a, it can be run in addition to the Armeabi architecture; If the project contains only x86, then the Armeabi architecture and armeabi-v7a Android devices will not work; if both Armeabi, armeabi-v7a and x86 are included, all devices can be run, and the program will load different platforms corresponding to so when it is running, which is a perfect solution, and also causes the package to become larger.
Androidndk How we should be aware of platform compatibility when developing packaging (X86,ARM,ARM-V7A)