Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to make Android Studio STOP generating local.properties?

I have set an environment variable ANDROID_HOME, which points to my android SDK location. However, every time I open my project in Android Studio it places local.properties file to the root of my project and copies my SDK location from ANDROID_HOME to this file. I want Android Studio use ANDROID_HOME directly, without generating local.properties.

Why? I'm on Windows 10 and I use Bash for Windows. I want to run command line using Bash while running Android Studio from Windows. For this I need two ANDROID_HOME environment variables, one for Windows, one for Bash. This is because although they point to the same (windows) android SDK the format is different, for Windows it is C:\Users\me\Android SDK while for Bash it's /mnt/c/Users/me/Android SDK. When Android Studio creates local.properties with windows path Bash becomes broken since apparently local.properties takes advantage over ANDROID_HOME, so I have to delete it manually.

like image 775
Denis Kniazhev Avatar asked Jan 20 '18 15:01

Denis Kniazhev


People also ask

Where is local properties in Android Studio?

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.

Do we need to set environment variables for Android studio?

Adding environment variables and java packages to use android studio and emulator. Before you start developing android apps or iOS apps with react native or with java/kotlin with android studio, you have to install a bunch of java stuff and set environment variables to path variables correctly.

How do I fix SDK location not found?

Close the current project and you'll see a pop-up with a dialog which will then proceed to Configure option. Configure -> Project Defaults -> Project Structure -> SDKs on left column -> Android SDK Home Path -> give the exact path as you did on local. properties and select Valid Target.


1 Answers

You might find this article useful:

Posix path conversion (mingw.org)

The gradle android plugin "Application" extension (your regular gradle-android interface) has a property sdkDirectory. Perhaps this can override it? I can't check.

I think there is a configuration switch for bash on Windows to parse path separators Windows-like, can't seem to find it, it is buried deep inside MinGW or MSYS docs I think.

Last resort - git Hooks. Read the ProGit book chapter on Hooks.

like image 158
Ate Somebits Avatar answered Oct 04 '22 22:10

Ate Somebits