diff options
authorRay Donnelly <>2013-03-28 23:50:30 +0000
committerThe Qt Project <>2013-04-03 00:37:48 +0200
commitb8c355bad24f6b9ea8e98cb387b7b8d1a178a655 (patch)
parentff58c27347603de1eff5651bdfa3a8f51c85291d (diff)
Android: Enable the java feature on Windows.
There is a bug in dx.bat in the Google Android SDK tool where relative paths do not work correctly. We need to use our own version of this tool until: merged. Change-Id: I451a3239590919d014a673f3e8e17244e96676ab Reviewed-by: Lars Knoll <> Reviewed-by: Eskil Abrahamsen Blomfeldt <> Reviewed-by: Oswald Buddenhagen <>
2 files changed, 107 insertions, 1 deletions
diff --git a/mkspecs/features/data/android/dx.bat b/mkspecs/features/data/android/dx.bat
new file mode 100644
index 0000000000..a60a1b4cbe
--- /dev/null
+++ b/mkspecs/features/data/android/dx.bat
@@ -0,0 +1,102 @@
+@echo off
+REM Copyright (C) 2007 The Android Open Source Project
+REM Licensed under the Apache License, Version 2.0 (the "License");
+REM you may not use this file except in compliance with the License.
+REM You may obtain a copy of the License at
+REM Unless required by applicable law or agreed to in writing, software
+REM distributed under the License is distributed on an "AS IS" BASIS,
+REM See the License for the specific language governing permissions and
+REM limitations under the License.
+REM If/when Google merge:
+REM this file will become redundant.
+REM don't modify the caller's environment
+REM Locate dx.jar in the directory where dx.bat was found and start it.
+REM Set up prog to be the path of this script, including following symlinks,
+REM and set up progdir to be the fully-qualified pathname of its directory.
+set prog=%~f0
+if [%1]==[] goto badArgs
+set "androidsdk=%1"
+shift /1
+if [%1]==[] goto badArgs
+rem Check we have a valid Java.exe in the path.
+set java_exe=
+call "%androidsdk%\tools\lib\find_java.bat"
+if not defined java_exe goto :EOF
+set jarfile=dx.jar
+set "frameworkdir=%androidsdk%\platform-tools"
+if exist "%frameworkdir%\%jarfile%" goto JarFileOk
+ set "frameworkdir=%androidsdk%\lib"
+if exist "%frameworkdir%\%jarfile%" goto JarFileOk
+ set "frameworkdir=%androidsdk%\framework"
+set jarpath=%frameworkdir%\%jarfile%
+set javaOpts=
+set args=
+REM By default, give dx a max heap size of 1 gig and a stack size of 1meg.
+rem This can be overridden by using "-JXmx..." and "-JXss..." options below.
+set defaultXmx=-Xmx1024M
+set defaultXss=-Xss1m
+REM Capture all arguments that are not -J options.
+REM Note that when reading the input arguments with %1, the cmd.exe
+REM automagically converts --name=value arguments into 2 arguments "--name"
+REM followed by "value". Dx has been changed to know how to deal with that.
+set params=
+if [%1]==[] goto endArgs
+set a=%~1
+ if [%defaultXmx%]==[] goto notXmx
+ if %a:~0,5% NEQ -JXmx goto notXmx
+ set defaultXmx=
+ :notXmx
+ if [%defaultXss%]==[] goto notXss
+ if %a:~0,5% NEQ -JXss goto notXss
+ set defaultXss=
+ :notXss
+ if %a:~0,2% NEQ -J goto notJ
+ set javaOpts=%javaOpts% -%a:~2%
+ shift /1
+ goto firstArg
+ :notJ
+ set params=%params% %1
+ shift /1
+ goto firstArg
+set javaOpts=%javaOpts% %defaultXmx% %defaultXss%
+call "%java_exe%" %javaOpts% -Djava.ext.dirs="%frameworkdir%" -jar "%jarpath%" %params%
+goto :EOF
+echo Usage: dx (for Qt) <android_sdk_path> <dx_arguments>
+echo Example: dx (for Qt) C:\android-sdk --dex --output=target.jar .classes
diff --git a/mkspecs/features/java.prf b/mkspecs/features/java.prf
index 05350db48d..029c3812e0 100644
--- a/mkspecs/features/java.prf
+++ b/mkspecs/features/java.prf
@@ -50,7 +50,11 @@ QMAKE_EXTENSION_SHLIB = jar
# Override linker with dex (for Android) or jar (for other java builds)
android {
QMAKE_LINK_O_FLAG = --output=
- QMAKE_LINK = $$SDK_ROOT/platform-tools/dx --dex
+ contains(QMAKE_HOST.os, Windows) {
+ QMAKE_LINK = $$PWD/data/android/dx $$SDK_ROOT --dex
+ } else {
+ QMAKE_LINK = $$SDK_ROOT/platform-tools/dx --dex
+ }
} else {