Hi I am new to QT and fairly new to programming as well. So sorry if I am not understanding the jargon. Now coming to the issue.
I am trying to compile the QgroundControl code for android.
Things I have done:
I have set up VDM in android studio
I have set up the android environment (JDK 21 NDK 21.3.6528147 SDK 11)
When compiling qmake and make steps seems to get excecuted properly without errors.
Problem is the Build Android APK
I have mostly followed all instructions in Overview · QGroundControl Developer Guide and the desktop version compiles no problem
Yeah, good luck there. I’ve been trying to compile the android version for many months with only limited success.
Fact is the whole Android side is completely outdated:
Mismatch of Java version required from build to what is in use these days.
Outdated Gradle version.
Finally you’ll get a password related error when trying to build the APK package. (Once again due to mismatch of Java versions)
There are many such reports on here with some helpful answers but haven’t found anything providing full step by step guidance.
My own work-around:
Building Android version in QT until same error as you’ve got pops up. Then closing project and re-opening in Android Studio. This will usually trigger a Gradle upgrade which I proceed with and then finalize the APK build. - But sometimes the essential Android build package hasn’t been created in QT so this work-around won’t work either.
Thank you for your reply.
If you dont mind me asking what versions of everything you use to compile it after the gradle update.
Could you maybe post a picture of your preferences page and “build apk” details in QT
The gradle update happens in Android Studio. From my experience don’t go past 7.6
(It starts with an upgrade to around 4.6, but if you refresh or re-load project it will offer to upgrade further)
My current QT was set to use Java 8 for the Android build kit as this was originally the requirement by QGC. However, I have, also managed to build with Java 11 (as currently stated in the QGC build instructions)
Yes, I need to do some modifications of the software and need that apk version. Have been trying for a week with no luck( but for now I am just trying to compile the stable daily build.) . Thank you for your settings ill try this out
I think I didn’t correctly use JDK 11 and ndk 19
I am now getting a new error in the make step.
But now I have JDK 11 and used Command line version 10 (only then JDK 11 works in QT)
In my case I did use NDK 21 as the 19 version keeps failing.
Both your screenshots indicate that you’ve used NDK 19. → Try NDK 21 instead.
Also stick with JDK 11 or no higher than 17.
Re. Android Studio:
I have also Android Studio installed and when the apk build fails in QT I close the project in Qt and start Android Studio and then load the project to finish apk build in there.
However, this only works if the Android build packages have been already created within QT.
Hey Karl,
I did what you said. compiled successfully but the apk didnt build on qt.
So I opened android studio, and I used the option import project(build.gradle …).
The android-build dir created a build.gradle file (so I assume this is how you import your project to android studio)
After which I was greeted by a java mismatch error which I managed to solve by installing newer gradle version 7.5 for this example.
Now I am getting this error seems to be related to line 37. Did you get this error ? Again many thanks
Looks to me that the Android Studio SDK hasn’t been installed as required.
But you could also google the error message and see what comes up. May just not be referenced internally in your OS.
If it is a Windows computer, have you re-started computer since installation of Android Studio?
Other than that looks like it is doing what it is supposed to do.
I assume you are talking about crashing using the emulator ?
I’ve never managed to get any of my apk’s working on the emulator, but they all seem to work fine on an actual device. ( I think it’s due to the fact that QGC is trying to communicate with the com ports but those are not there in the emulator)
Re. second screenshot. I’ve noticed you’ve got your build set for API 25. This is only useful for devices running up to Android 7. → Recommend changing that to API 32 in your build settings. (More files will have to be downloaded, but once installed can be used for future builds.)
Did you pull from master or stable ? …I’ve got in the past caught out with the master when someone had made changes but didn’t do any testing after. → Perhaps better sticking with stable branch.
Re. error: I think its a rather minor thing and may be linked to what I was saying above in regards to master branch.
I had similar issue as well once and simply stuck an icon in that folder with the name the build is looking for. → Important: Just adding a file to a folder might not work. Within QT you may have to right click on build tree and then select "Add File/Folder to build tree.
Thank you for your help I was able to compile it and deploy it. Also I was able to run it on my virtual machine as well as my device. Since there is very less resource on how to compile I’ll give a summary of the way I did it.
Install this package Version 5.15.2
Install Android Studio
Configure Android environment in QT: How?
i. Install JDK 11 - https://adoptium.net/temurin/releases/?arch=x64&package=jdk&version=11&os=windows and choose that location for JDK in QT
ii For SDK location, go to SDK Manager in Android Studio copy the path shown there.
iii Click Set up SDK and it will install necessary files required.
If you have red after this follow this step
open Android Studio> SDK Manager > SDK tools > (Check Show package Details ) > install Command line tools version 10.
Go to the sdk folder>cmdline-tools> rename 10 to latest
close qt open and it should work now (atleast it worked for me!)
I am also facing same issue, i am attempting to develop an application for both the Windows and Android platforms. The Windows build is functioning correctly; however, when I attempt to build it for Android, I encounter the following error:
/usr/bin/sh: line 1: C:UsersChris.LAppDataLocalAndroidSdkndk23.1.7779620/toolchains/llvm/prebuilt/windows-x86_64/bin/clang++: No such file or directory
Hi @Deathstroke69
Been reading up your post on QGC for Android. I am new to QGC and Qt. I want to disable a few parameters for the qgc android app but firstly, I am unable to build it on Qt. Using QT 6.6.1 as given on their website with JDK 21. The desktop app builds just fine. Initially got a lot of errors for not giving the r/w permission to certain folder paths. I have attached the error I am getting now. Could you help me out with this in case you have come across the same?
@Deathstroke69
Till step 3 I have done the setup.
I am not able to understand point 4 which is “change your AndroidManifest.xml File inside QT” – what I have to change here?
Regarding Point 5 - This folder is already getting created with Androidmanifest.xml file.
For me a different kind of error is coming.
I dont know why the path for toolchains is corrupted.
/usr/bin/bash: line 1: C:UsersmeAppDataLocalAndroidSdkndk21.3.6528147/toolchains/llvm/prebuilt/windows-x86_64/bin/clang++: No such file or directory