Where Does Local.Properties Go for Android Project

Where does local.properties go for android project?

The local.properties file goes in the project's root level, in the same folder as the gradlew, gradlew.bat, settings.gradle and other files.

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.

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 location not found. Define location with sdk.dir in the local.properties file or with an ANDROID_HOME environment variable

Please follow the below steps:

  • Go to your react-native Project then go to the android directory
    Create a file with the following name:

local.properties

  • Open the file and paste your Android SDK path like below:

For windows users:

sdk.dir=C:\\Users\\UserName\\AppData\\Local\\Android\\sdk

or (for newer versions of Android Studio / IntelliJ IDEA):

sdk.dir=C\:\\Users\\USERNAME\\AppData\\Local\\Android\\sdk

Where USERNAME your PC user name. Also, make sure the folder is sdk or Sdk.

Example:

sdk.dir=C:\\Users\\USERNAME\\AppData\\Local\\Android\\sdk

or:

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

For Mac users:

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

Where USERNAME is your OSX username.

For Linux (Ubuntu) users:

sdk.dir = /home/USERNAME/Android/Sdk

Where USERNAME is your linux username (Linux paths are case-sensitive: make sure the case of S in Sdk matches)

In case this doesn't work, add ANDROID_HOME variable in "Environment Variables" as C:\Users\USER\AppData\Local\Android\Sdk

Sample Image

Android: set sdk.dir in local.properties to ANDROID_HOME environment variable

local.properties should not be part of the versioned code. It's used as your local project configuration and Android Studio will create it based on on ANDROID_HOME if it doesn't exist yet.

If local.properties is not available, Gradle will use ANDROID_HOME automatically.

If local.properties is available, Gradle will use this file having a wrong sdk.dir set and fail.



Related Topics



Leave a reply



Submit