Peter Nied
Peter Nied

Reputation: 1885

Gradle cannot find the AndroidSDK path on Windows

I am just setting up a gradle build for a android project on a windows machine, after it has worked well on a mac. I have defined a local.properties file like so:

sdk.dir="C:\Program Files\android\sdk"

When attempting to use gradlew.bat I see the following:

C:\Users\PeterNied>gradlew

FAILURE: Build failed with an exception.

* Where:
Build file 'C:\Users\PeterNied\build.gradle' line: 9

* What went wrong:
A problem occurred evaluating project ':MyProject'.
> The SDK directory 'C:\Users\PeterNied\"C:Program Filesandroidsdk"' does         not exist.

* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.

BUILD FAILED

Total time: 3.224 secs

Clearly the computation of the android sdk directory is just combining the local directory and the destination that I specified C:\Users\PeterNied\"C:Program Filesandroidsdk". How do I point gradle to the right place?

Upvotes: 0

Views: 2315

Answers (2)

matiash
matiash

Reputation: 55370

Just using

sdk.dir=C:/Program Files/android/sdk

should work (in general, replacing backslashes by forward slashes).

The path separator and path concatenation are just the same issue.

Upvotes: 1

Peter Nied
Peter Nied

Reputation: 1885

There are two aspects of this problem, the path seperator, and dealting with the gradle local.dir + sdk.dir concatination:

  1. You can swap the '\' -> '/' in order to prevent the the path seperators from getting lost
  2. I've been unable to 'define' a root path for gradle to use instead, so I'm going to work around this problem by creating a path that will resolve to the right location like the following:

    sdk.dir=../../Program Files/android/sdk
    

Its a little ugly, but it will get you building.

Upvotes: 1

Related Questions