Tag Archives: libsjniLibs

Android about LIBS, jnilibs library basic instructions and conflict resolution

Programmer algorithm practice must read, common Java API skills to share>>>

Recently, we encountered a problem in the development, because the project needs to integrate different SDKs. The corresponding. So files are also different

There are some problems in the introduction of. So Library in LIBS

For example, to integrate a third-party NDK Library:

If you are in eclipse, you need to put it in the corresponding library directory under LIBS
in Android studio, the jnilibs directory in main will be matched by default. If there is no directory, you need to create it manually. And the name of the library can’t be changed at will

But there is a problem here. If you are using Android studio but want to use the Library under LIBS, you need to specify the location of the library manually

Add the following configuration in build.gradle under app

Android {

sourcesets {
main {
jnilibs. Srcdirs = [‘libs’]

}

}

}
1
2
3
4
5
6
7
8
9
10
11
when integrating the third-party service provider’s SDK, most of them will let you download demo, Or the SDK collection package allows you to directly copy the entire LIBS or jnilibs directory and merge local projects. This will cause problems

Take iFLYTEK voice development documents, baidu voice development documents and Aurora push documents as examples

IFLYTEK’s document states that all the files in the LIBS directory will be copied to the LIBS directory in its own project

Baidu’s is to copy all the files under app/SRC/main/jnilibs to its own project

Aurora documents are more humanized

If you want to integrate the first two SDKs, there will obviously be conflicts

After the build configuration, the jnilibs library cannot be recognized. But if it is not configured, LIBS library cannot recognize it
as a result, there is always one library that cannot load the. So file

So if you want to solve this problem, discard the previous documents

A little digression

Most of the NDK libraries provided by the third party are complete sets, in order to adapt to different CPU manufacturers, such as Qualcomm and MediaTek

When copying beiku, a complete set of copy into the project, generally four or five, baidu voice. So library all import words add up to more than 15m

Therefore, this is also a factor to be considered when choosing a third-party service<
take my demo as an example. Recently, the company has to choose a voice solution, so we have experienced Baidu’s and iFLYTEK’s for the time being

If you want to reduce the size of the installation package through the so library, you can also dynamically select the. So library to be added

Configure in build.gradle under app:

NDK {
// select the. So Library of the corresponding CPU type to be added
abifilters’ armeabi ‘,’armeabi-v7a’,’arm64-v8a ‘
// you can also add’ x86 ‘,’x86’_ In this way, the loading library can be specified

Reference to related documents:
some problems should be paid attention to when using so library with Android dynamic loading
detailed explanation of directory under Android jnilibs (. So file)

Project demo reference:
Android collection demo
— –
Author: wapchief
source: CSDN
Original: https://blog.csdn.net/wapchief/article/details/78229097
Copyright notice: This article is the original article of the blogger, please attach the blog link if you reprint it