Вопрос

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?

Это было полезно?

Решение

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.

Другие советы

i have had the Same issue with running Android-Studio on windows XP. After the Update it kept giving me the same error of Gradle: A problem occurred evaluating root project. so what i had to do is:

1- make sure you know where your android studio directory is in my case it was C:\Documents and Settings\UserName\Local Settings\Application Data\Android\android-studio\sdk

2- open the project root directory

3- locate the local.properties file and open it in a text editor notepad did it for me

4- change the sdk.dir="add your SDK directory here without the quotations" and make sure you use double instead of one on each separator sdk.dir=C:\\\Documents and Settings\\\UserName\\\Local Settings\\\Application Data\\\Android\\\android-studio\\\sdk

5- Rebuild your project

That was the only way it worked for me

For me the problem was that in OS X, I need set my ANDROID_HOME to a full path, such as:

export ANDROID_HOME="/Users/username/Development/android-sdk-macosx"

When using the user directory shorthand (~) Gradle seems to consider it a relative directory.

//according to my android studio project folder

just go into local file and open it into notepad then include the following line according to your project sdk file

sdk.dir=C\:/Users/raj/AppData/Local/Android/android-studio/sdk //

As for me ANDROID_HOME didn't work. It shows error that path is not found/exists which is totally stupid. Also I tried to create local.properties with sdk.dir=D:/android/sdk - this also wont work with the same error saying this path does not exist. What helped me - a RELATIVE PATH, so when I set

sdk.dir=../../../android/sdk

it starts to work

For those who are confused by: "This file is automatically generated by Android Studio. # Do not modify this file -- YOUR CHANGES WILL BE ERASED!" when they open local.properties :

It works anyway, if the file is overridden, just change it again.

To easily find the location of your sdk, try: File -> Project Structure -> Android SDK.

I had same issue, because my office PC is 32-bit and my home PC is 64 bit. In the local.properties file, I changed

sdk.dir=C:/Program Files/Android/android-studio/sdk

to

sdk.dir=C:/Program Files (x86)/Android/android-studio1/sdk

note the x86 version of Program Files

Took me forever to find it but this was fixed with buddahbrot's suggestion of creating a local.properties file in the root of your project folder to include sdk.dir= followed by the path to the sdk location.

This worked fine before with just ANDROID_HOME set in Windows but in OSX, I needed to specify with sdk.dir.

The most likely cause is the local.properties file is incorrect.

Check in the root folder and app folder for local.properties and make sure they point to the SDK folder. Both files must point to the SDK folder for this to work.

sdk.dir=C:\Users\me\AppData\Local\Android\Sdk

This works for me to get rid of "Try Again" on the top about Gradle errors.

File >> Project Structure >> Project >> Android Gradle Plugin Version = 3.2.1 and Gradle Version 5.1.1 >> Ok >> Apply

Android Studio >> Build >> Make Project

You may get fine, but it will pop-up again for "Update Gradle" I choose "Do not remind me for this project"

according to my android studio project folder

just go into local file and open it into notepad then include the following line according to your project sdk file

sdk.dir=C\:/Users/raj/AppData/Local/Android/android-studio/sdk //
Лицензировано под: CC-BY-SA с атрибуция
Не связан с StackOverflow
scroll top