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'}