android studio应用获取系统属性权限(SystemProperties)
dependencies {
provided files(getLayoutLibPath())
}
/** ZhangChao time:2014-12-31,get layoutlib.jar path. android.os.SystemProperties need it. */
// must called after "android" definition
def getLayoutLibPath() {
def rootDir = project.rootDir
def localProperties = new File(rootDir, "local.properties")
if (localProperties.exists()) {
Properties properties = new Properties()
localProperties.withInputStream {
instr -> properties.load(instr)
}
def sdkDir = properties.getProperty('sdk.dir')
def compileSdkVersion = android.compileSdkVersion
Console.println("app compileSdkVersion : " + compileSdkVersion)
def androidJarPath = sdkDir + "/platforms/" + compileSdkVersion + "/data/layoutlib.jar"
return androidJarPath
}
return rootDir
}