Android Studio package. so file tutorial

Source: Internet
Author: User

Android Studio package. so file tutorial
In eclipse ,. so file eclipse will help us automatically package into the apk file, usually in the: libs/armeabi directory, and then put libxxx. so copy to this directory, so NDK will automatically put this libxxx. so is packaged into the apk. After the apk is installed, it is placed in the your_apk_package_name/lib/directory.

Android studio is a little different. Next, let's introduce it to you. The method is very simple and you will learn it as soon as you learn it.

Here we will introduce three methods from the Internet and QQ groups:

1. From webpage:

Put the so file to be packaged into the apk into the libs directory under the project folder, and then build it in the app (note that it is in the app, not the project. add the following code to android {} In gradle:

sourceSets {    main {         jniLibs.srcDirs = ['libs']    }}

This is the case after adding (for example only ):

 

apply plugin: 'android' android {    compileSdkVersion 19    buildToolsVersion "19.0.0"     defaultConfig {        minSdkVersion 16        targetSdkVersion 19        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'])}

 

In this way, you can package the so file into the apk, which is available for the test.

2. From QQ group:

Create a directory in the project: jniLibs folder (same as the res directory), and then put the so file into it. You can automatically package it without configuring gradle.

This method is not tested, but it must be useful from the official google documentation.

 

3. webpage:

1) Create an empty folder "lib" anywhere on the hard disk (note that the name is "lib" instead of "libs ")

2) copy the armeabi folder under the original libs directory to the created lib directory. (The. so file in the armeabi folder will also be merged)

3) package and compress the created "lib" Directory into A. zip file and change it to "armeabi. jar"

4) Put armeabi. jar in the original libs directory (together with other third-party jar packages)

5) Update the as third-party database.

I agree with the method on the network and do not know whether it is applicable to the official version of.

Related Article

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.