android 项目的 local.properties 在哪里?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/20673378/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-20 03:14:25  来源:igfitidea点击:

Where does local.properties go for android project?

androidintellij-ideaandroid-build

提问by pfrank

Getting this complaint from IntelliJ 13:

从 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

I have tried to spam my local.properties in every directory I can think of but still getting this error. What gives?

我试图在我能想到的每个目录中向我的 local.properties 发送垃圾邮件,但仍然收到此错误。是什么赋予了?

回答by CJBS

The local.propertiesfile goes in the project's root level, in the same folder as the gradlew, gradlew.bat, settings.gradleand other files.

local.properties文件也要在项目的根目录中,在同一个文件夹中gradlewgradlew.batsettings.gradle和其他文件。

This file should not be included in source control. After (incorrectly) including this in source control, then deleting the file locally, Android Studio re-created the file for me automatically.

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

Here is the example content of this file:

这是此文件的示例内容:

## 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

Note the sdk.dir=reference to the location of the Android Studio SDK installation (which may be different on different machines).

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

回答by Tunvir Rahman Tusher

For MACcreate file local.propertiesinside android/and pastethis line inside the file

对于MAC创建的文件local.propertiesandroid/,并粘贴在文件中这一行

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

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