Advertisement
Guest User

lib.gradle

a guest
Feb 26th, 2015
408
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Groovy 1.89 KB | None | 0 0
  1. apply plugin: 'com.android.library'
  2.  
  3. android {
  4.     compileSdkVersion 21
  5.     buildToolsVersion "21.1.2"
  6.  
  7.     defaultConfig {
  8.         minSdkVersion 8
  9.         targetSdkVersion 21
  10.  
  11.         //ndk {
  12.         //    moduleName "libandroid_spatialite"
  13.         //}
  14.  
  15.         testApplicationId "org.spatialite.test"
  16.         testInstrumentationRunner "android.test.InstrumentationTestRunner"
  17.     }
  18.  
  19.     buildTypes {
  20.         release {
  21.         }
  22.     }
  23.  
  24.     // This tricks Gradle that there is no native source code to build,
  25.     // so we can build it with our custom task "ndkBuild"
  26.     sourceSets.main.jni.srcDirs = []
  27.  
  28.     splits {
  29.         abi {
  30.             enable true
  31.             reset()
  32.             include 'x86', 'armeabi', 'armeabi-v7a'
  33.             universalApk false
  34.         }
  35.     }
  36. }
  37.  
  38. // Howto "Using custom Android.mk with Gradle/Android Studio"
  39. // http://blog.gaku.net/ndk/
  40. // http://blog.gaku.net/including-ndk-produced-so-file-into-apk/
  41. // https://github.com/twitter-university/FibonacciNativeProject/tree/master/FibonacciNative
  42. // http://ph0b.com/android-studio-gradle-and-ndk-integration/
  43. task ndkBuild(type: Exec, description: 'Compile JNI sources via NDK') {
  44.     commandLine 'ndk-build',
  45.             'V=1',
  46.             '-j', Runtime.runtime.availableProcessors(),
  47.             'NDK_PROJECT_PATH=build',
  48.             'NDK_APPLICATION_MK=src/main/jni/Application.mk',
  49.             'APP_BUILD_SCRIPT=src/main/jni/Android.mk'
  50. }
  51.  
  52. task ndkLibsToJar(type: Zip, dependsOn: 'ndkBuild', description: 'Create a JAR of the native libs') {
  53.     destinationDir new File(buildDir, 'libs')
  54.     baseName 'ndk-libs'
  55.     extension 'jar'
  56.     from(new File(buildDir, 'libs')) { include '**/*.so' }
  57.     into 'lib/'
  58. }
  59.  
  60. tasks.withType(JavaCompile) {
  61.     compileTask -> compileTask.dependsOn ndkLibsToJar
  62. }
  63.  
  64. dependencies {
  65.     compile fileTree(dir: new File(buildDir, 'libs'), include: '*.jar')
  66. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement