remvee / android-mode

Emacs minor mode for Android application development
GNU General Public License v3.0
220 stars 57 forks source link

android-mode-sdk-dir as ANDROID_HOME reset #44

Closed parmegv closed 9 years ago

parmegv commented 9 years ago

android-mode-sdk-dir is a variable defined in `android-mode.el'. Its value is "~/Android/sdk" Original value was (getenv ANDROID_HOME)

Something changes the variable from the correct string (ANDROID_HOME, set by (exec-path-from-shell-copy-env "ANDROID_HOME")), to the default value.

remvee commented 9 years ago

I don't understand to problem. It currently sets android-mode-sdk-dir to ANDROID_HOME (when available) and otherwise "~/Android/sdk" on startup. You can use M-x customize-variable to change the value to the proper location when ANDROID_HOME is not available. Is that not what is happening in your case?

Please note: when you start emacs from some kind of launcher like the OSX dock, the environment variable set in for instance .profile are not available. Does (getenv "ANDROID_HOME") yield the expected location?

parmegv commented 9 years ago

Hi! Thanks for the attention.

(getenv "ANDROID_HOME") returns the correct value "C-h v android-mode-sdk-dir" returns "Its value is "~/Android/sdk", but it also says its original value was the correct value.

remvee commented 9 years ago

Hmm, setting the default value of a customization to a environment value and byte compilations do not seem to combine well. I've changed to semantics a bit; android-mode-sdk-dir still defaults to ~/Android/sdk but ANDROID_HOME is instead if available. Please try e45dd9f and let me know if that works for you.

parmegv commented 9 years ago

It finds adb properly, yay!

C-h v android-mode-sdk-dir still says its value is "~/Android/sdk", although there is a local.properties file with sdk.dir set and ANDROID_HOME is obviously set. I guess it works as expected, but the fact that the variable points to an unexpected directory may not be good.

Thanks for the fix! Waiting for a new elpa package :)

remvee commented 9 years ago

What about e67b6f5?

parmegv commented 9 years ago

It still works, but the variable is "nil" instead of "~/Android/sdk"

remvee commented 9 years ago

The variable does not matter. It's supposed to be a fallback value in case the SDK directory can not be determined from the local.properties file.

I do agree the default value is very rarely the right one for somebody elses system. Not having the default at all seems like the proper way to go.