문제

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.

도움이 되었습니까?

해결책

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

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

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top