Method for Android studio project to reference third-party so files

Application binary interface defines how binary files (especially. So files) run on the corresponding system platform, from the instruction set used, memory alignment to the available system function library. On Android system, each CPU architecture corresponds to an ABI: armeabi, armeabi-v7a, x86, MIPs, arm64 - v8a, MIPS64, x86_ 64。

The jar package is stored in the LIBS directory of the project.

Create a file called jnilibs under main

In addition, to add Android. Usedeprecatedndk = true in gradle.properties file, recompile the project.

When Android phones with different CPU architectures are loaded, they will find their corresponding directory under LIBS and the required. So files from the corresponding directory; If there is no corresponding directory, you will go to armeabi to find it. If there is already a corresponding directory, but if you do not find the corresponding. So file, you will not go to armeabi to find it. Therefore, you need to pay attention to the so file directories of the project configuration. You need to load the corresponding so file, otherwise an error will be reported.

How to adapt to various directories? For example, some third-party class libraries only provide. So files under armeabi, while the project configuration has more than one directory, so you need to copy the. So files under armeabi to other corresponding directories. If the third party provides. So files of different platforms, copy the. So files of different platforms to the corresponding folder in the project.

The so file will also affect the size of the compiled APK (extract the APK, and the Lib directory is the so file directory). Therefore, only one directory of armeabi is configured, which can not only adapt to the mobile phones of each CPU architecture, but also reduce the APK size (wechat is only one directory of armeabi).

summary

The above is the Android studio project introduced by Xiaobian to you. I hope it can help you. If you have any questions, please leave me a message and Xiaobian will reply to you in time. Thank you very much for your support for the programming tips website!

The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
分享
二维码
< <上一篇
下一篇>>