From 7d00aeb33e723d63267b8cd79632a912e887a29b Mon Sep 17 00:00:00 2001 From: Eike Ziller Date: Tue, 13 Aug 2019 10:53:30 +0200 Subject: [PATCH] Android: Make sure right Java is found in PATH We not only have to make sure that the Java path from the Qt Creator settings exists in the PATH, it must also be the one that is found when running Java tools. Otherwise having two different Java versions in the PATH can lead to the wrong one being run for the build. Fixes: QTCREATORBUG-22504 Change-Id: I22ff88fb334bb8ba5f719fbc3482c4629713409f Reviewed-by: Christian Stenger --- src/plugins/android/androidtoolchain.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/plugins/android/androidtoolchain.cpp b/src/plugins/android/androidtoolchain.cpp index 6f641bead3f..be8a9a79bf1 100644 --- a/src/plugins/android/androidtoolchain.cpp +++ b/src/plugins/android/androidtoolchain.cpp @@ -97,7 +97,8 @@ void AndroidToolChain::addToEnvironment(Environment &env) const if (javaHome.exists()) { env.set(QLatin1String("JAVA_HOME"), javaHome.toString()); const FilePath javaBin = javaHome.pathAppended("bin"); - if (!Utils::contains(env.path(), [&javaBin](const Utils::FilePath &p) { return p == javaBin; })) + const FilePath currentJavaFilePath = env.searchInPath("java"); + if (!currentJavaFilePath.isChildOf(javaBin)) env.prependOrSetPath(javaBin.toUserOutput()); } env.set(QLatin1String("ANDROID_HOME"),