Dynamically Loading so files

Source: Internet
Author: User

In the development process, third-party libraries are often used, such as maps, videos, document edits, charts, and so on. Depending on these libraries, you need to add their SDK, sometimes using the JNI layer of so files, such as Baidu map.

So the question is, what if there is a conflict between the so files of two different libraries?

For example: Add a library of maps separately, run no problem. Add a single video library and run without problems. But both are added, and one of the libraries errors when init. This certainly has a lot to do with the level of development of third-party libraries, but how do we solve this problem? This uses the method of dynamic loading.

This is the original static loading method, all dependent libraries of so files all a brain into the Armeabi folder.

Dynamically loaded methods, I put conflicting so files in the assets folder

It is important to note that dynamically loaded so files can only be placed in two places: 1. Lib folder, which corresponds to the Jnilibs folder in Android Studio. 2. Local data/data/package Data directory. Therefore, when the application first launches, we must put in the assets folder in the so file copy milk Local data directory.

Of course, the above method is to put so files in the program's assets folder. Alternatively, it can be downloaded from the network and placed in the local data directory. The advantage is that it not only reduces the size of the APK, but also makes it possible to use the latest dependent libraries at any time, which is one of the most useful applications for dynamic loading.

Dynamically Loading so files

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.