diff --git a/extras/Projucer/Source/Application/Windows/jucer_GlobalPathsWindowComponent.h b/extras/Projucer/Source/Application/Windows/jucer_GlobalPathsWindowComponent.h index 86ed55fd58..6346b80cdc 100644 --- a/extras/Projucer/Source/Application/Windows/jucer_GlobalPathsWindowComponent.h +++ b/extras/Projucer/Source/Application/Windows/jucer_GlobalPathsWindowComponent.h @@ -225,6 +225,9 @@ private: #endif addAndMakeVisible (pathPropertyComponents.add (new FilePathPropertyComponent (settings.getStoredPath (Ids::clionExePath), "CLion " + exeLabel, false))); + + addAndMakeVisible (pathPropertyComponents.add (new FilePathPropertyComponent (settings.getStoredPath (Ids::androidStudioExePath), + "Android Studio " + exeLabel, false))); } else { diff --git a/extras/Projucer/Source/ProjectSaving/jucer_ProjectExport_Android.h b/extras/Projucer/Source/ProjectSaving/jucer_ProjectExport_Android.h index 21aa0d9ea2..fd009d48c4 100644 --- a/extras/Projucer/Source/ProjectSaving/jucer_ProjectExport_Android.h +++ b/extras/Projucer/Source/ProjectSaving/jucer_ProjectExport_Android.h @@ -146,7 +146,7 @@ public: gradleToolchain (settings, Ids::gradleToolchain, getUndoManager(), "clang"), androidPluginVersion (settings, Ids::androidPluginVersion, getUndoManager(), "3.1.3"), buildToolsVersion (settings, Ids::buildToolsVersion, getUndoManager(), "28.0.0"), - AndroidExecutable (findAndroidExecutable()) + AndroidExecutable (getAppSettings().getStoredPath (Ids::androidStudioExePath).toString()) { name = getName(); @@ -276,38 +276,6 @@ public: overwriteFileIfDifferentOrThrow (gradleProjectFolder.getChildFile (filePath), outStream); } - //============================================================================== - static File findAndroidExecutable() - { - #if JUCE_WINDOWS - File defaultInstallation ("C:\\Program Files\\Android\\Android Studio\\bin"); - - if (defaultInstallation.exists()) - { - { - auto studio64 = defaultInstallation.getChildFile ("studio64.exe"); - - if (studio64.existsAsFile()) - return studio64; - } - - { - auto studio = defaultInstallation.getChildFile ("studio.exe"); - - if (studio.existsAsFile()) - return studio; - } - } - #elif JUCE_MAC - File defaultInstallation ("/Applications/Android Studio.app"); - - if (defaultInstallation.exists()) - return defaultInstallation; - #endif - - return {}; - } - protected: //============================================================================== class AndroidBuildConfiguration : public BuildConfiguration diff --git a/extras/Projucer/Source/Settings/jucer_StoredSettings.cpp b/extras/Projucer/Source/Settings/jucer_StoredSettings.cpp index def6cf3b2c..879d151065 100644 --- a/extras/Projucer/Source/Settings/jucer_StoredSettings.cpp +++ b/extras/Projucer/Source/Settings/jucer_StoredSettings.cpp @@ -365,6 +365,28 @@ Value StoredSettings::getFallbackPathForOS (const Identifier& key, DependencyPat v = "${user.home}/clion/bin/clion.sh"; } } + else if (key == Ids::androidStudioExePath) + { + if (os == TargetOS::windows) + { + #if JUCE_WINDOWS + auto path = WindowsRegistry::getValue ("HKEY_LOCAL_MACHINE\\SOFTWARE\\Android Studio\\Path", {}, {}); + + if (! path.isEmpty()) + return Value (path.unquoted() + "\\bin\\studio64.exe"); + #endif + + v = "C:\\Program Files\\Android\\Android Studio\\bin\\studio64.exe"; + } + else if (os == TargetOS::osx) + { + v = "/Applications/Android Studio.app"; + } + else + { + jassertfalse; // no Android Studio on this OS! + } + } } return v; @@ -436,6 +458,14 @@ bool StoredSettings::isGlobalPathValid (const File& relativeTo, const Identifier fileToCheckFor = "../clion.sh"; #endif } + else if (key == Ids::androidStudioExePath) + { + #if JUCE_MAC + fileToCheckFor = "Android Studio.app"; + #elif JUCE_WINDOWS + fileToCheckFor = "studio64.exe"; + #endif + } else if (key == Ids::jucePath) { fileToCheckFor = "ChangeList.txt"; diff --git a/extras/Projucer/Source/Utility/Helpers/jucer_PresetIDs.h b/extras/Projucer/Source/Utility/Helpers/jucer_PresetIDs.h index 48f73911e7..8a95c46079 100644 --- a/extras/Projucer/Source/Utility/Helpers/jucer_PresetIDs.h +++ b/extras/Projucer/Source/Utility/Helpers/jucer_PresetIDs.h @@ -220,6 +220,7 @@ namespace Ids DECLARE_ID (androidSharedLibraries); DECLARE_ID (androidScreenOrientation); DECLARE_ID (androidExtraAssetsFolder); + DECLARE_ID (androidStudioExePath); DECLARE_ID (iosDeviceFamily); const Identifier iPhoneScreenOrientation ("iosScreenOrientation"); // old name is confusing DECLARE_ID (iPadScreenOrientation);