[Android-development] Remove java code according to API level

Fabrice Mousset | GEOCEPT GmbH fabrice.mousset at geocept.com
Tue May 12 16:59:25 CEST 2020


Hi all,

I am developing Qt/Android applications which used a common Java code trunk.
Some applications are based on Qt 5.7.x and some on Qt 5.12.x.
So the supported API level is not same for each, because of Qt version.

I found if Qt documentation (https://doc.qt.io/archives/qt-5.7/deployment-android.html#androiddeployqt) there should be a way to exclude not supported code from java source code
//@ANDROID-28
    @Override
    public void onActivityReenter(int resultCode, Intent data)
    {
        // Do something
        return super.onActivityReenter(resultCode, data);
    }
//@ANDROID-28

androiddeployqt should remove this code from Java file, if API Level is lower than 28, but it is not the case.
Building the project with Qt 5.7, I've got this output:
Generating Android Package
  Input file: XXXX/android-XXXXX.so-deployment-settings.json
  Output directory: XXXX
  Application binary: XXXX
  Android build platform: android-21
  Install to device: No

But the marked code is still in java file and cannot be compiled!

What I am doing wrong?

Best regards

Fabrice Mousset


More information about the Android-development mailing list