Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

Gradle flavors



  • I need to create android app in couple versions which differs only in icon, splash screen and main screen text. I decided to use something that I heard about in the past, that is flavors from the gradle build system. As far as I understand it is enough (except adding flavorDimensions) to add additional sourceSet like flavor1 and assign variable:

    res.srcDirs = [qt5AndroidDir + '/res', 'res-flavor1']
    

    which is by default in main sourceSet:

    res.srcDirs = [qt5AndroidDir + '/res', 'res']
    

    And it seems to be ok, as icons from folder res-flavor1 are collected and put inside an apk file in the res folder instead of previously selected ones.
    Unfortunately there is a crash during startup

    10-24 08:13:04.297 26391 26415 E AndroidRuntime: java.lang.UnsatisfiedLinkError: No implementation found for boolean org.qtproject.qt5.android.QtNative.startQtAndroidPlugin(java.lang.String, java.lang.String) (tried Java_org_qtproject_qt5_android_QtNative_startQtAndroidPlugin and Java_org_qtproject_qt5_android_QtNative_startQtAndroidPlugin__Ljava_lang_String_2Ljava_lang_String_2)
    

    I checked content of a new apk file and after comparison with original one that is working, I found out that there are exactly the same plugins, however resources.arsc file is much smaller and the part which is missing (except some binary giberish, which I do not understand) looks like this:

    ^^--Added-by-androiddeployqt--/qml/QtGraphicalEffects/Blend.qml:qml/QtGraphicalEffects/Blend.qml
    xx--Added-by-androiddeployqt--/qml/QtGraphicalEffects/BrightnessContrast.qml:qml/QtGraphicalEffects/BrightnessContrast.qml
    ll--Added-by-androiddeployqt--/qml/QtGraphicalEffects/ColorOverlay.qml:qml/QtGraphicalEffects/ColorOverlay.qml
    ...
    JJlibplugins_bearer_libqandroidbearer.so:plugins/bearer/libqandroidbearer.so
    HHlibplugins_iconengines_libqsvgicon.so:plugins/iconengines/libqsvgicon.so
    ...
    

    So to sum up, by some strange reason if I add any flavor and copy all default values everything is ok, but if I modify resource directory, information about qmls and plugin files is not landing inside resource file. If i change default name of a resource directory from res to anything else the same thing happens.

    Should I create an issue on a bug tracker or this is completely my fault?

    Example code:

    • Use planets qml example - Planets QML Code
    • make a copy of android/res folder to android/res-flavor1
    • Open project in QtCreator and in Projects/Build Android APK->Create Templates (Accept)
    • Add some lines to build.gradle in android directory
        flavorDimensions "resources"
        productFlavors {
            flavor1 {
            }
        }
        sourceSets {
           ... // main source set
           flavour1 {
                res.srcDirs = [qt5AndroidDir + '/res', 'res-flavor1']
           }
        }
    
    • Inspect apk file (resources are there, libraries are there, assets file is much smaller then before)
    • Install and try to run

  • Banned

    This post is deleted!

Log in to reply