Gradle build errors after updating Android Studio

Matt Huggins picture Matt Huggins · Jun 15, 2013 · Viewed 89.6k times · Source

I just updated Android Studio, and now when I try to build my app, I get the following Gradle error:

Information: Compilation completed with 2 errors and 0 warnings in 28 sec
Information: 2 errors
Information: 0 warnings
Error: Gradle: : java.lang.NullPointerException
/Users/mhuggins/Sites/SmoothieFlow/build.gradle
    Error:(9, 0) Gradle: A problem occurred evaluating root project 'SmoothieFlow'.
                 > The SDK directory '/Users/mhuggins/Library/Caches/AndroidStudioPreview/compile-server/"/Applications/Android Studio.app/sdk"' does not exist.

Details about Android Studio version:

Android Studio (I/O Preview) AI-130.709792

Build #AI-130.709792, built on June 14, 2013

JDK 1.6.0_43

VM: Java HotSpot(TM) 64-Bit Server VM by Apple Inc.

Does anyone know why I'm getting this and what I can do to fix it?

Answer

buddahbrot picture buddahbrot · Jun 16, 2013

Try adding a new file in the root of your project called "local.properties" (or modify the existing one). It should contain

sdk.dir= 

followed by the path to the sdk location, in my case

sdk.dir=/Applications/Android Studio.app/sdk

I think Android Studio normally creates one automatically but says that it shouldn't be added to VCS. I put it in my .gitignore and cloned the project on my Mac which resulted in this error. Strangely before 0.1.5 it worked just fine without the file.