local.properties在哪里用于android项目?

时间:2013-12-19 04:18:41

标签: android intellij-idea android-build

从IntelliJ 13获取此投诉:

8:15:48 PM Gradle '<project>' project refresh failed:
           SDK location not found. Define location with sdk.dir in the local.properties file or with an ANDROID_HOME environment variable.
           Build file '/<project>/build.gradle' line: 20
           : Gradle settings

我试图在我能想到的每个目录中发送我的local.properties但仍然收到此错误。是什么给了什么?

2 个答案:

答案 0 :(得分:53)

local.properties文件位于项目的根级别,与gradlewgradlew.batsettings.gradle和其他文件位于同一文件夹中。

此文件不应包含在源代码管理中。在源代码管理中(错误地)将其包括在内,然后在本地删除文件后,Android Studio会自动为我重新创建该文件。

以下是此文件的示例内容:

## This file is automatically generated by Android Studio.
# Do not modify this file -- YOUR CHANGES WILL BE ERASED!
#
# This file must *NOT* be checked into Version Control Systems,
# as it contains information specific to your local configuration.
#
# Location of the SDK. This is only used by Gradle.
# For customization when using a Version Control System, please read the
# header note.
#Thu Aug 14 14:49:26 PDT 2014
sdk.dir=C\:\\Program Files (x86)\\Android\\android-studio\\sdk

请注意sdk.dir=对Android Studio SDK安装位置的引用(在不同的计算机上可能有所不同)。

答案 1 :(得分:2)

对于MAC,请在local.properties内创建文件android/,并在文件内的这一行粘贴

  

sdk.dir = /Users/USERNAME/Library/Android/sdk