Emmanouil Tsachalidis
Emmanouil Tsachalidis

Reputation: 21

Failure to compile Android application

I am on a Linux Mint 20.X distro.

I installed open source Qt Creator by using the online installer mainly targeting the building native Android applications with C/C++.

I had no experience with Qt Creator so I spent a couple of days trying to figure out how to install, what version, whether bugs existed in a version etc.

Since building native Android applications with C++ required the use of Qt Creator which includes many sub-components I realized there would be lots of different configurations and possible incompatibilities between them.

To start with I am attaching basic information screenshots of my Qt Creator setup:

About dialog: Based on Qt 5.15.2 (GCC 7.3.1 20180303, Red hat 7.3.1-5 64 bit)

I am using Oracle Java JDK 16.0.2 64bit but also tried openJDK from the distro's repos.

Tools->Options->Kits:
Tools->Options->Kits

In Tools->Options->Qt Versions I could see 6.13 in the auto-detected section and 5.12.8 in the manual (maybe a left over from previous installation attempts)

In Tools->Options->Devices->Android I could see that Java was reported with an OK, SDK location was the one I defined after being prompted by Qt creator during installation, NDK list was /home/manos/Android/sdk/ndk/21.3.6528147. I could see a green tick saying "Android settings are OK (SDK version 5.0, NDK version 21.3.6528147)"

I created two Android virtual devices at the bottom of the same dialog under the AVD tab and I ticked & installed the SDK platform and APIs for Android 10 & 11 under the SDK tab.

After installing Qt Creator, I went straight to Tools->options where I get to download all required components by Qt Creator.

That went smooth after confirming licenses.

Next, I created a desktop pc new application which also went smooth ant built without errors.

I then created my first Android application by following the screenshots below:

In New project dialog I chose Qt Quick Application - Empty.

In Project location I named the project folder "new-mobile-app-ARM64-v8a" and create in field value was /home/manos/Projects/Qt-Creator.

In Define build system dialog I chose qmake.

In Required Qt version - I chose ver. 6 from the drop down list that contained 5.12, 5.13, 5.14, 5.15 & 6.0.

In Kit selection dialog I chose ARM64-v8a clang compiler.

After creating the project I got no errors. When trying to build it I got the following error:

Could not initialize class org.codehaus.groovy.runtime.InvokerHelper

Full error log:

FAILURE: Build failed with an exception.

BUILD FAILED in 326ms Building the Android package failed! & Ndash; For more information, run this command with & ndash; verbose.

  1. 03:49: The process "/home/manos/.programs/qt6/6.1.3/gcc_64/bin/androiddeployqt" exited with code 14. Error while building/deploying project new-mobile-app-ARM64-v8a (kit: Android Qt 6.1.3 Clang ARM64-v8a) When executing step "Build Android APK"

  2. 03:49: Elapsed time: 00:02.

Later I noticed that gradle was involved in this error.

I searched in S.O and found that one of the suggestions was to change the distributionUrl value to another version greater than 6.3. Mine was 5.6.4. I went to https://gradle.org/releases/ and saw that the latest was 7.2 So I tried: distributionUrl=HTTPS://services.gradle.org/distributions/gradle-7.2-bin.zip

I tried to build again and I got this error:

Execution failed for task ':processDebugManifest'.

Full error log:

FAILURE: Build failed with an exception. Deprecated Gradle features were used in this build, making it incompatible with Gradle 8.0.

You can use ' & ndash; warning-mode all' to show the individual deprecation warnings and determine if they come from your own scripts or plugins.

See https://docs.gradle.org/7.2/userguide/command_line_interface.html#sec:command_line_warnings 9 actionable tasks: 9 executed

BUILD FAILED in 701ms Building the Android package failed! & Ndash; For more information, run this command with & ndash; verbose.

  1. 14:59: The process "/home/manos/.programs/qt6/6.1.3/gcc_64/bin/androiddeployqt" exited with code 14. Error while building/deploying project new-mobile-app-ARM64-v8a (kit: Android Qt 6.1.3 Clang ARM64-v8a) When executing step "Build Android APK".

  2. 14:59: Elapsed time: 00:02.

Even though I searched I could not find any simple solution.

I tried a few different combinations of qt versions & kits when creating a new project. I always got the same error.

I have been struggling to make this work for at least 2 full days.

Upvotes: 1

Views: 1271

Answers (1)

Emmanouil Tsachalidis
Emmanouil Tsachalidis

Reputation: 21

Problem was solved by downgrading my java version to ver. 11.

Turns out i was looking at the wrong place for 2 days straight.

There is a comprehensive table of compatibility between gradle and java.

Look here: https://docs.gradle.org/current/userguide/compatibility.html.

The default version of gradle being used was unfortunately 5.6.4 as i discovered in the file gradle-wrapper.properties located in the build folders that will be created after you try to build your project.

There is a line:

distributionUrl=https://services.gradle.org/distributions/gradle-5.6.4-bin.zip

where the 5.6.4 must be replaced with a valid version.

After you select Build you will notice in the log that the new gradle zip file will be downloaded.

I tried java open jdk 11 with gradle 5.6.4 (default) which worked. Then i tried java open jdk 13 with gradle 6.5 which also worked. So the conclusion here is that the correct java version must be used with respect to gradle.

Don't forget to update the java version in menu Tools->Options->Devices, Tab Android->JDK location: /usr/lib/jvm/java-XX-openjdk-amd64/ (which applies for openJDK. Substitute XX with the version that you want to use.

In linux you have to install off course the java that you want to use by typing: sudo apt install openjdk-XX-jdk which may be different in your distro.

Upvotes: 1

Related Questions