How to package the. So file in APK

Source: Internet
Author: User

How to package the. So file in APK
There are two methods,
1 is added to the Android. mk file.
Local_jni_shared_libraries: = libxxx
In this way, ndk will automatically package libxxx into APK during compilation;
In the youapk/lib/directory.

2. Create an application directory
Libs/armeabi
Directory, and then copy libxxx. So to this directory,
In this way, the ndk will automatically package libxxx. So into the APK.
In the youapk/lib/directory.

In the code, use
System. loadlibrary ("XXX ");
You can load this dynamic library.
Note that you only need to write the parameter XXX. You do not need to write libxxx or libxxx. So.

Another note is that the system. loadlibrary function will search for the libxxx. So file in the following path:
/System/lib
/Data/You APK package/lib

However, if libxxx. So still depends on other. So files, such as libyyy. So, system. loadlibrary will only
Find it in the/system/lib directory. If it is not found, it will not automatically go to/data/You APK package/lib
Continue searching. At this time, an error will be reported if the dynamic library is not found;
The solution is to load libyyy. So before load libxxx. So, as follows:
System. loadlibrary ("yyy ");
System. loadlibrary ("XXX ");

 

 

 

 

 

Bytes -------------------------------------------------------------------------------------------------

Premise: the so file is compiled in the source code and exists in the intermediate file of the compilation output. For example, the libtest. So file must be in the out/target/product/generic/obj/lib/libtest. So
In this way, write the Android. mk File
Add the following assignment statement:
Local_jni_shared_libraries: = libtest
You can.
For how to enable the compilation system to automatically add other resource files to the APK during compilation, refer to compile system files.
Build/CORE/package. mk
The compilation process of the local_jni_shared_libraries field.

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.