Add the JNI so file to the Android Studio Gradle Project

Source: Internet
Author: User

Add the JNI so file to the Android Studio Gradle Project

First, create the entire jni directory under the app directory of the Android Studio (version 1.2.2) project. The jni directory contains Android. mk, Application. mk, various C/C ++ and Assembly source files. Then, use the ndk_build tool to compile the file. Then the tool automatically generates the libs Directory, which contains every so file of the processor architecture you specified in Application. mk.

If you reference a third-party so, directly store the relevant files in the libs directory.

Edit the build. gradle file in the app directory and add the following code to it:

 

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

 

 

The complete build. gradle file is as follows:

 

 

apply plugin: 'com.android.application'android {    compileSdkVersion 22    buildToolsVersion 22.0.1    defaultConfig {        applicationId com.qianmi.myapp        minSdkVersion 15        targetSdkVersion 22        versionCode 1        versionName 1.0    }    buildTypes {        release {            minifyEnabled false            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'        }    }    lintOptions {        disable 'InvalidPackage'    }    sourceSets {        main {            jniLibs.srcDirs = ['libs']        }    }    packagingOptions {        exclude 'META-INF/services/javax.annotation.processing.Processor'    }}dependencies {    compile fileTree(dir: 'libs', include: ['*.jar'])    compile 'com.android.support:appcompat-v7:22.2.0'    compile 'com.google.code.gson:gson:2.3'    compile 'com.mcxiaoke.volley:library:1.0.16'    compile 'com.android.support:design:22.2.0'    compile 'com.android.support:cardview-v7:22.2.0'    compile 'com.android.support:recyclerview-v7:22.2.0'    compile 'com.github.bumptech.glide:glide:3.6.0'    compile 'com.jakewharton:butterknife:7.0.1'}


 

 

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.