Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. Mobile and Embedded
  4. Gradle flavors
Forum Update on Monday, May 27th 2025

Gradle flavors

Scheduled Pinned Locked Moved Unsolved Mobile and Embedded
2 Posts 2 Posters 538 Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • J Offline
    J Offline
    Jarek B
    wrote on last edited by Jarek B
    #1

    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
    1 Reply Last reply
    1
    • R Offline
      R Offline
      Rachel298
      Banned
      wrote on last edited by
      #2
      This post is deleted!
      1 Reply Last reply
      1

      • Login

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • Users
      • Groups
      • Search
      • Get Qt Extensions
      • Unsolved