[Development] Changes to Qt Android Java Bindings

Assam Boudjelthia assam.boudjelthia at qt.io
Mon Aug 28 13:06:04 CEST 2023


Hey,

Qt Android team is planning some changes around the Qt Android plugin. Specifically, changes to refactor the Java bindings, simplify them and get rid of complex or redundant code. The current Java bindings live under  https://github.com/qt/qtbase/tree/dev/src/android/java/src/org/qtproject/qt/android/bindings. The main concerns with the current code is its use of reflection and the somehow convoluted relation between QtActivity, QtActivityDelegate and QtActivityLoader. At the moment, reflection calls are used to invoke certain implementation from the delegate class in the Activity class, where quite many duplicated logic is involved.

The aim with this work is to:
- Get rid of reflection usage.
- Get rid of duplicated logic (so far it looks like it’s hundreds of lines).
- Get to redesign the architecture and relation between the different parts involved.
- Document how all that work properly.
- Improve future maintainability of the Android plugin.

In more details:
- De-duplicate code between various QtLoader classes.
- Remove unnecessary overrides in Activity/Service classes.
- De-duplicate the various constants.
- Move QtActivityDelegate into the new QtActivityBase which hakes the various overridden implementations by Qt.
- QtActivityBase extends Activity, and QtActivity extends the former, so it doesn’t need reflection to tap into the Qt implementations.
- The Loader classes are moved outside of the bindings and into the internal Android Jar package.

We have WIP patches are under the chain https://codereview.qt-project.org/c/qt/qtbase/+/483592.

Now, since this is a heavy change, it might break some use cases for existing projects. So I’m looking for any feedback for such use cases, concerns or any objections of this change. Also, suggestions for anything that makes sense to be done at the same time as this change. We track the work on this at https://bugreports.qt.io/browse/QTBUG-114593, so any feedback on this thread of ticket is welcome!

Best regards,
Assam
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.qt-project.org/pipermail/development/attachments/20230828/3a20b946/attachment.htm>


More information about the Development mailing list