Skip to content

Instantly share code, notes, and snippets.

@pocmo
Created September 6, 2013 08:38
Show Gist options
  • Star 4 You must be signed in to star a gist
  • Fork 3 You must be signed in to fork a gist
  • Save pocmo/6461138 to your computer and use it in GitHub Desktop.
Save pocmo/6461138 to your computer and use it in GitHub Desktop.
(Android) Gradle: Copy native libraries into final APK
// Tested with gradle 1.7 and android plugin 0.5.6
// [..] Your gradle build script
// Copy *.so files from libs/ folder of your project to native-libs folder
// Adjust if your native libraries are somewhere else..
task copyNativeLibs(type: Copy) {
from(new File(project(':yourproject').projectDir, 'libs')) { include '**/*.so' }
into new File(buildDir, 'native-libs')
}
// Whenever the code is compiled, also copy the native libs to the build folder
tasks.withType(Compile) { compileTask -> compileTask.dependsOn copyNativeLibs }
// On "gradle clean" also reverse the copying of the native libraries
clean.dependsOn 'cleanCopyNativeLibs'
// Include the native-libs folder into the final APK
tasks.withType(com.android.build.gradle.tasks.PackageApplication) { pkgTask ->
pkgTask.jniDir new File(buildDir, 'native-libs')
}
@pookie13
Copy link

pookie13 commented Jun 7, 2016

hello dear,
hopefully you are doing well. can you please let me know how to use .so file in my project in android studio.
i will be your greatfull thanking you.

skype id: piyush.gupta326

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment