升级Android Studio后的Gradle构建错误。

时间:2021-06-30 18:54:29

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

我刚刚更新了Android Studio,现在当我尝试构建我的应用程序时,我得到了如下的Gradle错误:

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版本的详细信息:

Android Studio (I/O Preview) AI-130.709792

Android Studio (I/O预览)AI-130.709792。

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

建造#AI-130.709792,建于2013年6月14日。

JDK 1.6.0_43

JDK 1.6.0_43

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

VM:苹果公司的Java HotSpot(TM) 64位服务器VM。

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

有人知道我为什么要这么做吗?我能做些什么来修复它?

10 个解决方案

#1


135  

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

尝试在项目的根目录中添加一个名为“local”的新文件。属性(或修改现有属性)。它应该包含

sdk.dir= 

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

接下来是到sdk位置的路径,在我的例子中。

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.

我认为Android Studio通常会自动创建一个,但是它说它不应该被添加到VCS。我把它放在我的。gitignore,并在我的Mac上克隆了这个项目,结果导致了这个错误。奇怪的是,在0.1.5之前,没有文件,它照样运行。

#2


9  

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:

我在windows XP上运行android studio也遇到过同样的问题。更新后,它不断给我同样的等级错误:一个问题发生在评估根项目。所以我要做的是

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

1 -确保你知道你的android工作室目录在哪里对于我来说这是C:\Documents and Settings\UserName\Local设置\ \ android \ android-studio \ sdk应用程序数据

2- open the project root directory

2-打开项目根目录。

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

3 -找到地方。属性文件并在文本编辑器记事本中打开它为我做了。

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

4 -改变sdk。“在这里添加您的SDK目录,无需引用”,并确保在每个分隔符SDK上使用double而不是one。(C) \\\ \\\ \\\ \\\ \\\ \\\ \\\ \\\ \\\ \\\ \\ * \\\ \\\ \\\ \\\ \\\ \\\ \\\ \\\ \ * \\\ \\\ \\\ \\\ \\\ \\\ - \\\ \\\ \\\

5- Rebuild your project

5 -重建项目

That was the only way it worked for me

这是我唯一的办法。

#3


7  

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

对我来说,问题是在OS X中,我需要将ANDROID_HOME设置为完整路径,比如:

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

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

当使用用户目录速记(~)级时,似乎认为它是一个相对目录。

#4


2  

//according to my android studio project folder

//根据我的android studio项目文件夹。

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

只需进入本地文件并将其打开到记事本,然后根据您的项目sdk文件包含以下行。

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

sdk。dir = C:\ /用户/ raj / AppData /地方/ Android / android-studio / sdk / /

#5


2  

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

至于我,ANDROID_HOME没有工作。它显示了没有找到路径的错误,这是完全愚蠢的。我也试着创造一个地方。属性与sdk。D:/android/sdk——这也不会有相同的错误,说这条路径不存在。是什么帮助了我——一个相对的路径,所以当我设置的时候!

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

it starts to work

它开始工作

#6


1  

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 :

对于那些困惑的人:“这个文件是由Android Studio自动生成的。不要修改这个文件——你的修改将被删除!属性:

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.

要轻松找到您的sdk的位置,请尝试:File ->项目结构-> Android sdk。

#7


0  

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

我有同样的问题,因为我的办公电脑是32位的,我的家用电脑是64位。在当地。属性文件,我改变了

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

sdk。dir = C:/ / Android / android-studio / sdk程序文件

to

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

sdk。dir = C:/程序文件(x86)/ Android / android-studio1 / sdk

note the x86 version of Program Files

请注意程序文件的x86版本。

#8


0  

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.

我花了很长时间才找到它,但这是用佛陀的建议创造了一个地方。属性文件在项目文件夹的根目录中包含sdk。接下来是到sdk位置的路径。

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

在Windows中使用ANDROID_HOME设置之前,这个工作很正常,但是在OSX中,我需要指定sdk.dir。

#9


0  

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文件夹。这两个文件都必须指向SDK文件夹以使其工作。

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

sdk.dir = C:\ Android用户当地\ \我\ AppData \ \ Sdk

#10


-1  

according to my android studio project folder

根据我的android studio项目文件夹。

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

只需进入本地文件并将其打开到记事本,然后根据您的项目sdk文件包含以下行。

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

#1


135  

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

尝试在项目的根目录中添加一个名为“local”的新文件。属性(或修改现有属性)。它应该包含

sdk.dir= 

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

接下来是到sdk位置的路径,在我的例子中。

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.

我认为Android Studio通常会自动创建一个,但是它说它不应该被添加到VCS。我把它放在我的。gitignore,并在我的Mac上克隆了这个项目,结果导致了这个错误。奇怪的是,在0.1.5之前,没有文件,它照样运行。

#2


9  

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:

我在windows XP上运行android studio也遇到过同样的问题。更新后,它不断给我同样的等级错误:一个问题发生在评估根项目。所以我要做的是

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

1 -确保你知道你的android工作室目录在哪里对于我来说这是C:\Documents and Settings\UserName\Local设置\ \ android \ android-studio \ sdk应用程序数据

2- open the project root directory

2-打开项目根目录。

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

3 -找到地方。属性文件并在文本编辑器记事本中打开它为我做了。

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

4 -改变sdk。“在这里添加您的SDK目录,无需引用”,并确保在每个分隔符SDK上使用double而不是one。(C) \\\ \\\ \\\ \\\ \\\ \\\ \\\ \\\ \\\ \\\ \\ * \\\ \\\ \\\ \\\ \\\ \\\ \\\ \\\ \ * \\\ \\\ \\\ \\\ \\\ \\\ - \\\ \\\ \\\

5- Rebuild your project

5 -重建项目

That was the only way it worked for me

这是我唯一的办法。

#3


7  

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

对我来说,问题是在OS X中,我需要将ANDROID_HOME设置为完整路径,比如:

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

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

当使用用户目录速记(~)级时,似乎认为它是一个相对目录。

#4


2  

//according to my android studio project folder

//根据我的android studio项目文件夹。

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

只需进入本地文件并将其打开到记事本,然后根据您的项目sdk文件包含以下行。

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

sdk。dir = C:\ /用户/ raj / AppData /地方/ Android / android-studio / sdk / /

#5


2  

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

至于我,ANDROID_HOME没有工作。它显示了没有找到路径的错误,这是完全愚蠢的。我也试着创造一个地方。属性与sdk。D:/android/sdk——这也不会有相同的错误,说这条路径不存在。是什么帮助了我——一个相对的路径,所以当我设置的时候!

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

it starts to work

它开始工作

#6


1  

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 :

对于那些困惑的人:“这个文件是由Android Studio自动生成的。不要修改这个文件——你的修改将被删除!属性:

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.

要轻松找到您的sdk的位置,请尝试:File ->项目结构-> Android sdk。

#7


0  

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

我有同样的问题,因为我的办公电脑是32位的,我的家用电脑是64位。在当地。属性文件,我改变了

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

sdk。dir = C:/ / Android / android-studio / sdk程序文件

to

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

sdk。dir = C:/程序文件(x86)/ Android / android-studio1 / sdk

note the x86 version of Program Files

请注意程序文件的x86版本。

#8


0  

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.

我花了很长时间才找到它,但这是用佛陀的建议创造了一个地方。属性文件在项目文件夹的根目录中包含sdk。接下来是到sdk位置的路径。

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

在Windows中使用ANDROID_HOME设置之前,这个工作很正常,但是在OSX中,我需要指定sdk.dir。

#9


0  

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文件夹。这两个文件都必须指向SDK文件夹以使其工作。

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

sdk.dir = C:\ Android用户当地\ \我\ AppData \ \ Sdk

#10


-1  

according to my android studio project folder

根据我的android studio项目文件夹。

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

只需进入本地文件并将其打开到记事本,然后根据您的项目sdk文件包含以下行。

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