Learn what Felgo offers to help your business succeed. Start your free evaluation today! Felgo for Your Business

Forums

OverviewFelgo 3 Support (Qt 5) › nativeUtils implementation

Viewing 8 posts - 1 through 8 (of 8 total)
  • Author
    Posts
  • #24739

    Volker

    Hi dear Felgo team,

    I’m currently moving some part of application into separate module (qml plugin) to use it from 2 different apps. This part has also Java code for Android that gets  called via JNI. But by qml plugins there is no androiddeployqt step, so I have no idea how to move Java code into plugin. Could you give me some hints how you have implemented it in nativeUtils?

    Kind regards

    #24794

    Volker
    #24795

    Christian
    Felgo Team

    Hi Volker!

    To use custom Java code with a QML plugin, you can package  it into a JAR or AAR file (either with Android Studio or command line javac/jar commands) and then add it to your application’s build.gradle file.

    Let us know if you need more detailed instructions how to set it up.

    Best,
    Christian

    #24796

    Volker

    Hi Christian,

    thank you for the info. If I use plugin with different apps, should I adjust namespace (package name) for every app or is it possible to use it’s own package name in QML plugin? But Plugin has no manifest file. And if I need to adjust package name for each app, it’s not very different with using java directly in app project instead of plugin. May be there is some trick to make package name variable?

    Regards

     

    #24797

    Christian
    Felgo Team

    HI Volker,

    I think you can use any package name you like for the Java plugin.

    Just package your classes into a JAR file (or AAR if there’s more than just Java code) and then add that to any application’s build.gradle file.

    E.g.

    dependencies {
      implementation files("libs/plugin-android.aar")
    }

    You can use the same plugin for multiple apps then (which themselves can have unique, different application IDs).

    Hope this helps!
    Christian

    #24800

    Volker

    Hi Christian,

    thanks, it works now. The only problem I had was Java class that extends QtService. In order to compile it I had to add Java sources from

    Felgo/android/src/android/java/src/org/qtproject/qt5/android/bindings/ and then Ministro aidl. But then I could not use aar inside my project because ministro were found in project and in aar library. Unfortunately I didn’t find way to fix it and ended up with commenting Service class out (not used at the moment). But if you have hint how to solve this I would be very appreciate.

    Regards

    #24806

    Christian
    Felgo Team

    Hi Volker,

    there are 2 options to solve this:

    1. You can exclude the extra classes from the AAR build. You can use a “compileOnly” dependency for this. You would have to package the extra sources into a JAR file and then add them to your plugin project like

    dependencies {
      compileOnly files("libs/qt-templates.jar")
    }

    2. You can exclude specific packages when adding the AAR to your app’s build.gradle like this:

        implementation files('libs/plugin-android.aar') {
            exclude group: 'org.qtproject'
        }

    More info: https://docs.gradle.org/current/userguide/dependency_downgrade_and_exclude.html

    Best,
    Christian

    #24807

    Volker

    Hi Christian,

    for me dependencies->compileOnly didn’t work for aidl and java sources. But I compiled all staff together, then got classes.jar from generated aar, removed my classes and put it as qt_deps.jar into compileOnly deps. This way it works now.

    Regards

Viewing 8 posts - 1 through 8 (of 8 total)

RSS feed for this thread

You must be logged in to reply to this topic.

Qt_Technology_Partner_RGB_475 Qt_Service_Partner_RGB_475_padded