Skip to content

Instantly share code, notes, and snippets.

@lyaotian
Last active December 23, 2015 23:19
Show Gist options
  • Select an option

  • Save lyaotian/6708985 to your computer and use it in GitHub Desktop.

Select an option

Save lyaotian/6708985 to your computer and use it in GitHub Desktop.
/*
* Compress the native libs located at libs/armeabi/ into archive file
* libs/armeabi.jar
* Destination directory inside the archive is lib/armeabi/<libs>
*
* Example of .jar needed structure :
* |---lib/
* |---armeabi/
* |---libdatabase_sqlcipher.so
* |---libsqlcipher_android.so
* |---libstlport_shared.so
* |---x86/
* |---libdatabase_sqlcipher.so
* |---libsqlcipher_android.so
* |---libstlport_shared.so
*
* reference : https://groups.google.com/forum/?fromgroups#!searchin/adt-dev/so/adt-dev/nQobKd2Gl_8/Z5yWAvCh4h4J
*/
task nativeLibsToJar(
type: Zip,
description: 'create a jar archive of the native libs') {
destinationDir file('./libs')
baseName 'native-libs'
extension 'jar'
from 'libs/armeabi'
include '**/*.so'
into 'lib/armeabi'
}
tasks.withType(Compile) {
compileTask -> compileTask.dependsOn(nativeLibsToJar)
}
clean.dependsOn 'cleanNativeLibsToJar'
You have to add the generated archive as a dependency :
dependencies {
compile files('libs/native-libs.jar')
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment