Question

Till now the follwing was working:

android.plugin.sdkDirectory

With Gradle 1.10+ however it is no longer possible. As a workaround I am currently using the following code:

def localProperties = new File(project.rootDir, "local.properties")
if (localProperties.exists()) {
    Properties properties = new Properties()
    localProperties.withInputStream { instr ->
        properties.load(instr)
    }
    def sdkDirProp = properties.getProperty('sdk.dir')

    if (sdkDirProp != null) {
        //YEAH WE HAVE THE ANDROID SDK DIR! NOW DO SOMETHING WITH IT!
    }
}

This however is a huge effort compared to the single line I was able to use before. Is there a solution I am missing?

Also the workaround might get deprecated since it uses a private constant FN_LOCAL_PROPERTIES = "local.properties" which I currently have hardcoded.

Was it helpful?

Solution

Just use android.sdkDirectory instead of android.plugin.sdkDirectory

See https://plus.google.com/114432517923423045208/posts/NphSRvqAo6m

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top