[Interest] QML Plugin with Java (Android)

Ben Lau xbenlau at gmail.com
Tue Sep 16 19:07:26 CEST 2014


On 17 September 2014 00:30, Brian Dentino <brian.dentino at gmail.com> wrote:

> I am trying to write a QML plugin that will work on both iOS and Android.
> The iOS implementation requires a mix of C++ & Objective C on the backend,
> while the Android implementation requires some C++ & Java. I struggled
> yesterday with figuring out the best way to deploy this Java alongside an
> application/project that wants to use this plugin on Android.
>
> For now, I've settled on the following method, but I don't believe it's
> ideal because I had to modify the androiddeployqt tool to get what I want
> and it requires a developer to follow some implicit naming conventions when
> creating jars:
>
> 1. Compiling the plugin java to a .jar (bundled and non-bundled versions,
> as with QtAndroidBearer) when building the plugin.
>
> 2. Installing the plugin (.so and .jar) post-build to the
> [QT_INSTALL_PREFIX]/qml directory (alongside the built-in qml plugins).
>
> 3. Modifying a few lines of code in the androiddeployqt tool to detect
> .jar files when scanning qml imports and package these .jars in the /lib
> folder of the dependent application. Checks for a '-bundled.jar' suffix if
> the deployment method is 'bundled'.
>
> Is anyone aware of a better/easier way to do this? It seems that the only
> built-in way to specify jar dependencies for deployment is by creating a
> new Qt module, which seems overkill for this plugin I'm working on. And
> from what I can tell, ANDROID_PACKAGE_SOURCE_DIR is intended more for use
> with individual standalone applications, not qml plugins.
>
> Brian
> _______________________________________________
> Interest mailing list
> Interest at qt-project.org
> http://lists.qt-project.org/mailman/listinfo/interest
>

Hi Brian,

I think qmake could handle the task for you. Example script (never tested
for jar file, just copy from my project) :

ANDROID_BUILD_DIR = $$OUT_PWD/android-build

xxx-jars.target = $$ANDROID_BUILD_DIR/libs/xxx.jar

xxx-jars.commands = $(COPY_DIR) somehwre/xxx.jar
$$ANDROID_BUILD_DIR/libs/xxx.jar

target.depends += xxx-jars
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.qt-project.org/pipermail/interest/attachments/20140917/bd39cd16/attachment.html>


More information about the Interest mailing list