Priority: Not Evaluated
Affects Version/s: Qt Creator 4.2.1, Qt Creator 4.3.0-beta1
Fix Version/s: None
Component/s: Android Support
Environment:Qt 5.8, androiddepployqt, Alpine Linux Grsec, Android build tools 25, NDK r10e, QtCreator 4.2.1 enterprise, Gradle 3.3, Android Studio 2.3-beta3
( This relates to the fix in
When trying to do builds using Gradle versions newer than 2.x androiddeployqt builds will fail because the previous fix for missing distributionUrl does an exact regexp match for gradle version 2.x and otherwise modify the distributionUrl to using gradle-2.2.1-all.zip. The build fails as follows:
The following is in build.gradle:
and in gradle-wrapper.properties:
The stable Android Studio 2.2.x use Gradle 2.x, while Android Studio 2.3 Beta3 now use Gradle 3.3 - causing the regexp match to modify the newer gradle version in gradle-wrapper.properties. See
My project Qmake contains:
For others possibly running into the same problem - I avoid the modification from androidmanager.cpp by moving the wrapper folder one level up and changing the CLASSPATH in gradlew from gradle/wrapper/gradle-wrapper.jar to wrapper/gradle-wrapper.jar and similarly change the path in the project Qmake file.
Also, rather than inject QtCreator Build Environment variables, I autodetect what executes the gradlew script (but a simple env variable from QtCreator or CI/CLI androiddeployqt would suffice) by adding in the same gradlew script somewhere after line 26:
This change make Gradle builds using QtCreator put all Gradle caching etc on the same level as the shadow build folders, but GRADLE_USER_HOME could be set anywhere fixed as e.g. ~/Qt/.gradle, ~/Qt/Tools/QtCreator/.gradle or just use the default ~/.gradle location. The latter interferes somewhat with Android Studio, so some users using QtCreator and Android Studio on the same project workspace report build problems concerning Gradle versions. For developers with project Java files in $$PWD/android/src/ this might be an issue.
The recommended way for Gradle builds is to include the gradlew scripts as well as the gradle/wrapper/ folder in version control - see:
Version controlling the build toolchain also makes sense for continuous integration (CI) and for having reproducable builds. Docker images makes that even more robust... although the Google Android Sdk calls home to check the license key - so the same license key as used by someone accepting license agreement should be used in such images.
For making this the default for new QtCreator projects with a Qt installation, put the gradlew scripts and wrapper/gradle-wrapper.* into e.g ~/Qt/5.8/android_armv7/src/android/templates/.
Also remember an important $$PWD/android/.gitignore with:
Looking forward to more native mobile goodies and bundle size trimming with Qt 5.9 - especially cool if using Android fragments, mixing native surfaces could become a bit more straigthforward using Qt. BogDan Vatra, also holding the candle for Android NDK clang and newer NDK version support in 5.9. Hope you can continue the Android episodes for more native stuff like fragments, surfaces or sensors etc in QML. Great stuff!