From 2cde2fca6f7b584fd01c0e3eec0209447963b665 Mon Sep 17 00:00:00 2001
From: Eskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@digia.com>
Date: Thu, 16 May 2013 14:35:54 +0200
Subject: [PATCH] Fix Qt for Android build with recent SDK bundle

In the recent revisions of the Android SDK bundle, the dx
tool has moved from platform-tools/ and into
build-tools/<revision-number> where revision-number is 17.0.0 at
the moment. To enable building on these SDKs, we add
detection for the dx tool and an environment variable which
can be set to override the revision number to provide a way
to build it against future revisions as well.

Task-number: QTBUG-31199
Change-Id: I0d6a22163dc2e50f7a81cd3fe8f3d53c6335aaee
Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@digia.com>
Reviewed-by: Paul Olav Tvete <paul.tvete@digia.com>
---
 mkspecs/features/java.prf | 7 +++++++
 1 file changed, 7 insertions(+)

diff --git a/mkspecs/features/java.prf b/mkspecs/features/java.prf
index 25f6e66427d..7360103757b 100644
--- a/mkspecs/features/java.prf
+++ b/mkspecs/features/java.prf
@@ -7,6 +7,11 @@ android {
         isEmpty(API_VERSION): API_VERSION = android-10
     }
 
+    isEmpty(BUILD_TOOLS_REVISION) {
+        BUILD_TOOLS_REVISION = $$(ANDROID_BUILD_TOOLS_REVISION)
+        isEmpty(BUILD_TOOLS_REVISION): BUILD_TOOLS_REVISION = 17.0.0
+    }
+
     !exists($$SDK_ROOT/platforms/$$API_VERSION/android.jar) {
         error("The Path $$SDK_ROOT/platforms/$$API_VERSION/android.jar does not exist. Make sure the ANDROID_SDK_ROOT and ANDROID_API_VERSION environment variables are correctly set.")
     }
@@ -56,7 +61,9 @@ android:!bundled_jar_file {
         DEX_CMD = $$PWD/data/android/dx $$SDK_ROOT
     } else {
         DEX_CMD = $$SDK_ROOT/platform-tools/dx
+        !exists($$DEX_CMD): DEX_CMD = $$SDK_ROOT/build-tools/$$BUILD_TOOLS_REVISION/dx
     }
+    !exists($$DEX_CMD): error("The path $$DEX_CMD does not exist. Please set the environment variable ANDROID_BUILD_TOOLS_REVISION to the revision of the build tools installed in your Android SDK.")
     QMAKE_LINK_SHLIB_CMD = $$DEX_CMD --dex --output $(TARGET) $$CLASS_DIR
 } else {
     QMAKE_LINK_SHLIB_CMD = jar cf $(TARGET) -C $$CLASS_DIR .
-- 
GitLab