in Eclipse,. So files eclipse will help us automatically package the apk file, usually placed in: Libs/armeabi directory, Then copy the libxxx.so to this directory so that the NDK will automatically pack the libxxx.so into the APK and install the apk After the location is placed in the your_apk_package_name/lib/directory.
Android Studio is a little different, let's introduce you, the method is very simple, a learning will be.
Here we introduce three ways, from the network and QQ Group:
1. From Web page :
Put the so file that needs to be packaged into the APK into the Libs directory under the project folder and add the following code to Android {} in the app (note that the app is not project-Build.gradle)
<span style= "FONT-SIZE:14PX;" ><span style= "FONT-SIZE:14PX;" >sourcesets { main { jnilibs.srcdirs = [' Libs '] }}</span></span>
This is the case when added (only for example):
<span style= "FONT-SIZE:14PX;" >apply plugin: ' Android ' Android { compilesdkversion buildtoolsversion ' 19.0.0 ' defaultconfig { minsdkversion targetsdkversion versioncode 1 versionname "1.0" } buildtypes { Release { Runproguard false proguardfiles getdefaultproguardfile (' proguard-android.txt '), ' Proguard-rules.txt ' } } sourcesets { main { jnilibs.srcdirs = [' Libs '] }}} dependencies { Compile filetree (dir: ' Libs ', include: [' *.jar '])}</span>
So that you can pack so files into the APK, which is the author of a pro-test available.
2. From QQ Group:
Create a new directory within the project: Jnilibs folder (sibling to res directory), and then put so files in it without configuring Gradle to automatically package
This method, not tested, but from official Google Docs, is certainly useful.
From QQ group: Android Studio Tech
3. From Web page :
1) Create an empty folder "Lib" at any location on the hard disk (note that the name is "Lib" instead of "Libs")
2) Copy the Armeabi folder from the original Libs directory to the newly created Lib directory. (The. So file in the Armeabi folder will also be copied in)
3) package The newly created "Lib" directory into a. zip file and rename it "Armeabi.jar"
4) put Armeabi.jar into the original Libs directory (and other third-party jar packages)
5) Update as third-party library
The network is quite agreeable to the method, do not know suitable for the official version of AS.
After this event, it was found that browsing official documents is very important, but in the celestial "Great Wall", but the pain of our developers. I hope you have like-minded friends: busy also want to see official documents! Be busy and look at Android encryption
Android Studio Packaging. So files tutorial