Gradle official has already implemented the automatic packaging. So file feature in the new version.
You only need to configure it in the Android directory in the Build.gradle file:
1 sourcesets { 2 main { 3 jnilibs.srcdirs = [' Libs '] 4 } 5 }
The complete build.gradle configuration file is as follows:
1Apply plugin: ' Com.android.application '2 3 Android {4 5Compilesdkversion 216Buildtoolsversion "21.1.1"7 8 Defaultconfig {9ApplicationID "Com.johntsai.voicerecognize"TenMinsdkversion 14 OneTargetsdkversion 21 AVersioncode 1 -Versionname "1.0" - } the Buildtypes { - Release { -Minifyenabledfalse -Proguardfiles getdefaultproguardfile (' proguard-android.txt '), ' Proguard-rules.pro ' + } - } + Sourcesets { A Main { atJnilibs.srcdirs = [' Libs '] - } - } - } - Dependencies { -Compile Filetree (include: [' *.jar '], dir: ' Libs ') inCompile ' com.android.support:appcompat-v7:21.0.2 ' -Compile files (' Libs/msc.jar ') to}
Android Studio Add so files and package them into the Lib folder of the APK