Android Studio Packaging. So files tutorial

Source: Internet
Author: User

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 the Web:

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 {         = [' Libs ']    }}</span></span>

This is the case when added (only for example):

 
<span style= "FONT-SIZE:14PX;" >apply plugin: ' Android 'Android {compilesdkversion19buildtoolsversion"19.0.0"Defaultconfig {minsdkversion16targetsdkversion19Versioncode1Versionname"1.0"} buildtypes {release {Runproguardfalseproguardfiles 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 the Web:

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

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.