view app/build.gradle @ 447:2907c688955e

add ndk shared object to .apk package
author Carl Byington <carl@five-ten-sg.com>
date Thu, 17 Mar 2016 13:24:58 -0700
parents ced663d2e957
children 7492d2cb7b75
line wrap: on
line source

task copyDebugLibTask(type: Copy) {
    from 'build/intermediates/binaries/debug/arm/lib/armeabi'
    into 'src/main/jniLibs/armeabi'
}
task copyReleaseLibTask(type: Copy) {
    from 'build/intermediates/binaries/release/arm/lib/armeabi'
    into 'src/main/jniLibs/armeabi'
}

tasks.whenTaskAdded { task ->
    if (task.name.contains("merge") && task.name.contains("JniLibFolders")) {
        if (task.name.contains("ArmDebug")) {
            task.dependsOn copyDebugLibTask
        }
        if (task.name.contains("ArmRelease")) {
            task.dependsOn copyReleaseLibTask
        }
    }
}


apply plugin: 'com.android.model.application'

model {
    android {
        compileSdkVersion = 16
        buildToolsVersion = "23.0.2"
        buildTypes {
            release {
                minifyEnabled = false
                signingConfig = $("android.signingConfigs.release")
            }
            debug {
                debuggable = true
                ndk {
                    debuggable = true
                }
            }
        }
        productFlavors {
            create("arm") {
                ndk.abiFilters.add("armeabi")
            }
            create("x86") {
                ndk.abiFilters.add("x86")
            }
        }
        ndk {
            moduleName = "com_google_ase_Exec"
            cppFlags.add("-Werror")
            ldLibs.add("log")
        }
        sources {
            main {
                jni {
                    source {
                        srcDir "Exec"
                    }
                }
            }
        }
        defaultConfig.with {
            applicationId = "com.five_ten_sg.connectbot"
            minSdkVersion.apiLevel = 8
            targetSdkVersion.apiLevel = 15
        }
    }

    android.signingConfigs {
        create("release") {
            def console = System.console()
            if (console) {
                storePassword = new String(console.readPassword("\nkey store password: "))
                keyPassword   = new String(console.readPassword("\nkey alias password: "))
            }
            else {
                def read = System.in.newReader().&readLine
                print "\nkey store password"
                storePassword = read()
                print "\nkey alias password"
                keyPassword   = read()
            }
            storeFile = file("../510Connectbot.keystore")
            storeType = "jks"
            keyAlias  = "510Connectbot"
        }
    }
}