日々精進

新しく学んだことを書き留めていきます

./gradlew buildを実行すると「SDK location not found. Define location with sdk.dir in the local.properties file or with an ANDROID_HOME environment variable.」エラー

原因はlocal.propertiesがプロジェクトルートに無いこと。 local.propertiesを作り、中身を以下のようにすればよい。

## 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.
#Wed Jan 07 15:34:05 JST 2015
sdk.dir=/Users/username/android-sdk-macosx

sdk.dirの指定に~/や$HOME/は使えなかった。なぜだ。。

参考:

http://android.benigumo.com/20130816/android-studio-0-2-4-%E3%82%A2%E3%83%83%E3%83%97%E3%83%87%E3%83%BC%E3%83%88%E3%81%A7%E3%80%8Csdk-location-not-found-define-location-with-sdk-dir-in-the-local-properties-file-or-with-an-android_home-e/