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

HowTo run Android from QtC with --user


  • Qt Champions 2016

    Just doing my first AndroidForWork App for one of my customers.
    Will blog about the details later.

    With AndroidForWork (AfW) your Android device is managed by IT and there are private apps and work apps.
    I managed to deploy app to Android Device from QtC.
    Sideloading Apps to AfW devices the app will be installed as private and work app.
    https://developer.android.com/work/managed-profiles.html#testing_apps
    QtC does this well.
    But then QtC runs the private App. This is because QtC uses the default User.
    With AfW there are 2 users. You can list them:

    adb shell pm list users
    

    private user has always ID 0 and Work User will have another ID - I always have seen ID 10.
    I can run the Work App I deployed using QtC from this command:

    adb shell am start --user 10 -n my.package.name/org.qtproject.qt5.android.bindings.QtActivity
    

    So my question: HowTo tell QtC to use an extra argument '--user 10' while starting the APK ?
    As a mobile business app developer I don't have so much knowledge about QtC Android BuildProcess.
    From QtC developer list I got a hint to use a custom Run Configuration.
    So I entered:
    Executable: adb
    Arguments: shell am start --user 10 -n my.package.name/org.qtproject.qt5.android.bindings.QtActivity
    WorkingDir: %{buildDir}
    Tried with or without checking the 'Run in terminal box'
    but getting an error:

    Cannot find the androiddeploy Json file.
    Error while building/deploying project my_project (kit: Android for armeabi-v7a (GCC 4.9, Qt 5.7.0))
    When executing step "Deploy to Android device"
    

    curious: I did no changes to deployment. it's still saying 'Deploy to Android Device'

    would be cool to manage AndroidForWork completely from inside QtC.

    BTW: I'm on OSX and Device is connected via USB

    At the moment my workflow is something like this:

    • deploy and run from QtC (deploys private and work app and runs private app)
    • exit the private app on Android Device
    • run work app from my Mac (adb start --user10 - see above-
    • Terminal: adb start-server
    • Run OSX App LogRabbit (http://lograbbit.com/ ) to monitor the Android LogCat output

    Of course would be much easier to run the work app from QtC and to watch logs from ApplicationOutput Pane in QtC

    thx for any help


  • Qt Champions 2016

    cool: Qt Creator 4.4 will have run settings. So starting the Android Work App with --user 10 will be easy:
    https://bugreports.qt.io/browse/QTCREATORBUG-17862


  • Lifetime Qt Champion

    Hi,

    You should take a look at Qt Creator's AndroidRunner class, that might get you what you want.

    Hope it helps



  • Hi @ekkescorner
    I see you posted on the Android-development mailing list too, that is good.
    You could try the Interest list too.

    You might be among the first AfW Qt developers out there.


  • Qt Champions 2016

    @tekojo said in HowTo run Android from QtC with --user:

    Hi @ekkescorner
    I see you posted on the Android-development mailing list too, that is good.
    You could try the Interest list too.

    You might be among the first AfW Qt developers out there.

    yep. there are not so many out there but it's an important topic for Google and Enterprise -
    and it will be a door-opener forr Qt @ enterprise if development-cycle is smooth


  • Qt Champions 2016

    @SGaist said in HowTo run Android from QtC with --user:

    Hi,

    You should take a look at Qt Creator's AndroidRunner class, that might get you what you want.

    Hope it helps

    thx for the info, but I have no idea what to do
    have in mind I'm a mobile business app developer relying on IDE doing all the 'dirty' jobs for me ;-)

    perhaps I should open an Issue to put something like a AndroidUserId variable into .pro and QtC Android buildprocess includes --user nn into adb start if this var is set


  • Lifetime Qt Champion

    Sorry, you are right I didn't take that point into account. I was thinking about that class as a likely place to start looking at in order to modify Qt Creator to fit your needs.

    Personally, I think it would make more sense to see that in Qt Creator's project configuration panel.

    I'd recommend opening a feature request about that matter for Qt Creator.


  • Qt Champions 2016

    cool: Qt Creator 4.4 will have run settings. So starting the Android Work App with --user 10 will be easy:
    https://bugreports.qt.io/browse/QTCREATORBUG-17862


Log in to reply