1 apply plugin: 'com.android.application'
5 buildToolsVersion "20.0.0"
8 applicationId "org.iotivity.ca.sample_service"
13 moduleName "RMInterface"
20 proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
30 manifest.srcFile 'src/main/AndroidManifest.xml'
32 jni.srcDirs = [] //disable automatic ndk-build call
38 compile fileTree(dir: 'libs', include: ['*.jar'])
39 compile project(':cAInterface')
42 task copyNativeLibs(type: Copy, dependsOn: 'buildNative') {
43 dependsOn 'buildNative'
44 from(new File('src/main/libs')) { include '**/*.so' }
45 into new File(buildDir, 'native-libs')
48 tasks.withType(JavaCompile) { compileTask -> compileTask.dependsOn copyNativeLibs }
50 clean.dependsOn 'cleanCopyNativeLibs'
52 tasks.withType(com.android.build.gradle.tasks.PackageApplication) { pkgTask ->
53 pkgTask.jniFolders = new HashSet<File>()
54 pkgTask.jniFolders.add(new File(buildDir, 'native-libs'))
57 task buildNative(type: Exec) {
58 if (System.env.ANDROID_NDK_HOME != null) {
59 //for windows use 'ndk-build.cmd'
60 //def ndkBuild = new File(System.env.ANDROID_NDK_HOME, 'ndk-build.cmd')
61 def ndkBuild = new File(System.env.ANDROID_NDK_HOME, 'ndk-build')
62 commandLine ndkBuild, "-C", file("src/main"), "-B", "-j", Runtime.runtime.availableProcessors(),
63 "APP_ABI=$TARGET_ARCH", "APP_OPTIM=$RELEASE"
65 println '##################'
66 println 'Skipping NDK build'
67 println 'Reason: ANDROID_NDK_HOME not set.'
68 println '##################'