If you’re developing mobile business apps sooner or later customers will request to debug, build and run on managed devices. This blog post is focused on Google for Work | Android Enterprise (aka Android for Work).

Google for Work | Android Enterprise

There are different ways to run work applications: devices may only contain work apps or private and work apps are installed together. From my experiences in most cases there are private and work apps together on devices. Read more about EMM (Enterprise Mobile Management) and different scenarios here.

For stages 2 and 3 your device must be activated as Android for Work device or you should request a device to test on from your customer. This is the only way to get access to data servers behind the firewall – in most cases there will be no URL you can use from outside. One device can only be activated as work device for one server (BlackBerry UEM).

It’s highly recommended to test your APP as Work APP – the admin can forbid features (Bluetooth, NFC, Camera, …)

To manage apps your customer has to use a Google developer account to be able to publish apps through Google Play for Work.

Multi Android Package Names in Manifest

Attention: you must change the Android package name to enable your customer publishing the app to Google Play for work because the package name from stage 1 is already connected to your own Google developer account from Beta testing.

Also your Enterprise Customers can have different environemts for dev, test, production with different Google Developer Accounts to get a specific Play Store for Work for each environment. This means you must build releases for up to three or more different package names. Changing the package name manually in Android Manifest is not so comfortable. You can have a dynamic way following this blog article.

Best would be Qt Creator supports this directly using variables in .pro. see QTCREATORBUG-17863

Using the Drawer or Bottom Navigation Bar some color from pressing the buttons down remains after fingers are released. This happens on Android and iOS and the amount of color is different from case to case – sometimes not easy to detect.

Here are some screenshots so you can verify if this happens also in your apps:

–

Running example Apps like QtQuickControls2 Gallery all works well.

It took me some time to have a small reproducable test case and I opened QTBUG-59293

Again @jpnurmi could help and provides a patch.

Material: force ripple background when hidden

Now it’s easy to patch.

Hint: this time we must do this for the Android kit and also for the iOS kit.

Open a Terminal and do this to patch your Android Kit.

Attention: I’m using the Android repo I already cloned for the first patch.

I’m not using the Maintenance Tool – I’m always installing a new Qt Release at a different location and also start Qt Creator with -settingsPath as blogged here

Then it’s easier to work with old and new release side-by-side and compare.

Update QML Imports

From a technical point you can use the ‘old’ imports. I’m always doing search/replace to update the imports. Then I’m sure all my QML files are accessing the newest Controls and Properties. Updating from 5.7 to 5.8 I replaced

As next I’m testing my Conference Apps. These Apps are something more complex and I also test building release and upload to Google Play Beta Test and Apple TestFlight to see if Release also is working.

Opening the generated Xcode project and then doing the build again all is working as expected. Even deleting the build dir and building again it works.

This is caused by Xcode automatic provisioning and out of scope from Qt. (see QTBUG-59350)

So don’t panic if the iOS build fails – simply open the Xcode project one time.

QML import could not be resolved

Building Android Apps you’ll see some warnings like

Warning: QML import could not be resolved in any of the import paths: org.ekkescorner.data
Warning: QML import could not be resolved in any of the import paths: QtQuick.Controls.impl
Warning: QML import could not be resolved in any of the import paths: QtQuick.Controls.Material.impl
Warning: QML import could not be resolved in any of the import paths: QtQuick.Controls.Universal.impl

Unfortunately I wasn’t able to create a small test scenario yet, but will try again and open an Issue later.

Most important: You can ignore this Warning.

Please update your kit or choose a mkspec for qmake

Configuring a project for iOS I got

"/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang++" is used by qmake, but "/usr/bin/clang++" is configured in the kit.
Please update your kit or choose a mkspec for qmake that matches your target environment better.

-headerpad_max_install_names is ignored

:-1: warning: -headerpad_max_install_names is ignored when used with -bitcode_bundle (Xcode setting ENABLE_BITCODE=YES)

From qt-creator List I got confirmation that this can be ignored. See also codereview 185929 –

so next Qt releases will have this fixed.

member of multiple groups (“Supporting Files” and “Resources”)

Compiling a project for iOS it may happen that you get some warnings like this:

xcodebuild[5107:303392] warning: The file reference for "/daten/_qt_workspaces/work_580/c2gQtCon_x/images.qrc" is a member of multiple groups ("Supporting Files" and "Resources"); this indicates a malformed project. Only the membership in one of the groups will be preserved (but membership in targets will be unaffected). If you want a reference to the same file in more than one group, please add another reference to the same path.

Fortunately this Warning again can be ignored. But it’s annoying building releases with hundreds of warnings. Thx to @jakepetroules I got infos HowTo patch bitcode.prf. You’ll find this file here:

...sdk_580/5.8/ios/mkspecs/features/uikit/bitcode.prf

Open this file and replace the content by:

lessThan(QMAKE_XCODE_VERSION, "7.0") {
warning("You need to update Xcode to version 7 or newer to support bitcode")
} else: !macx-xcode {
# Simulator builds and all debug builds SHOULD use -fembed-bitcode-marker,
# but unfortunately the -fembed-bitcode and -fembed-bitcode-marker driver
# flags do not work in conjunction with -Xarch, so we'll have to let it use
# the "wrong" flags for now (note that this issue affects only the Makefile
# generator). We also don't want the flags to be passed in Xcode builds, as
# the Xcode ENABLE_BITCODE setting will take care of that for us.
release {
QMAKE_CFLAGS += -fembed-bitcode
QMAKE_CXXFLAGS += -fembed-bitcode
QMAKE_OBJECTIVE_CFLAGS += -fembed-bitcode
QMAKE_LFLAGS += -fembed-bitcode
} else {
QMAKE_CFLAGS += -fembed-bitcode-marker
QMAKE_CXXFLAGS += -fembed-bitcode-marker
QMAKE_OBJECTIVE_CFLAGS += -fembed-bitcode-marker
QMAKE_LFLAGS += -fembed-bitcode-marker
}
}

Now all -fembed-bitcode-marker issues are gone 🙂

Now we’re leaving the comfort zone.

Buttons remain some color of ripple effect

Suddenly I noticed a strange behavior in my more complex apps: Using the Drawer or Bottom Navigation Bar some color from pressing the buttons down remains after fingers are released. Fortunately this was fixed soon and the Drawer is working again (see patch)

Only one use-case left, where the Menu ToolButton remains some color:

Seems the ripple effect wasn’t reset completely while the Drawer is opening on top. At the moment I didn’t found a way to create a small test-case, but will try later agein.

Fortunately I found a workaround using a Loader toggling between two different Components of same ToolButton.

Adding OpenSSL

As you probably know, Google removed openssl from Android7, so you have to add openssl libraries built by yourself.

My first projects with Qt 5.7 have used http only (they’re running behind firewalls on managed devices so this is secure)

All worked well without the need to add openssl – but it was on my ToDo list.

Qt 5.8 did some things different and now my Qt 5.8 apps are crashing from QNetworkAccessManager. From discussions in Qt Forums I’ve seen I’m not the only one seeing these differences between 5.7 and 5.8

Read more about Open Source vs Commercial also in my blog about ‘Install Qt 5.6‘

Here are my steps to download and install Qt 5.8 (commercial):

Install Qt 5.8

Go to your Qt Account – Downloads and select the Qt Online Installer:

See available downloads:

I selected the macOS online installer:

Here’s my download on OSX:

Double click to install:

Log into your Account:

Select the folder where to install:

It’s a good idea to use installation pathes without spaces. see also here.

As next select your components:

please notice: some components from commercial are now included into the open source part.

and wait for the installer:

If Installer finished, I’m not launching Qt Creator yet.

Start Qt Creator with -settingsPath

All Qt Creator instances by default share the settings. Having the new Qt Creator 4.2.1 and old 4.0.2, 3.6.2 using the same settings is no good idea. Also I want to use different working directories for my Qt 5.6, 5.7 and the new Qt 5.8 Release.

You can start Qt Creator with parameter -settingsPath – here’s HowTo do this from OSX:

Search for the Qt Creator.app from Qt 5.8 and do a right-click on the app. Here’s the content:

rename Qt Creator to something like Qt Creator-bin:

From a Text Editor create a Script to execute the Qt Creator-bin with a parameter.

Qt Creator will create the QtProject folder to sthore all the configuration settings.

Now you can start multiple Qt Creator versions without any collision.

Qt Creator 4.2.1

At first I’m changing QtCreator’s language on my german MacBookPro to english and restart

Select your Theme. I’m using the Flat Theme:

Qt Creator Preferences Working Directory

Set your working directory for 5.8, if you are using different directories as I’m doing:

Qt Creator Preferences Android

Take a look at your Devcies -> Android preferences:

Select your SDK and NDK locations and check ‘Gradle’:

Important: Don’t use a newer NDK ! Please always use r10e because of some trouble with the newer ones.

Qt Creator External Tools

I’m developing business apps and business apps always need support of languages (i18n). Configuring the External Tools for Linguist (Qt’s Tool to translate text from your QML and C++ sources) will make it more comfortable.

I like to use Tools in english, but the language cannot be changed yet for Linguist, so the trick is to rename the translations file, which in my case is 5.8 –> clang_64 –> translations –> linguist_de.qm:

Under Preferences –> Environment –> External Toolsthere already exist access to commands for lupdate and lrelease. (lupdate is looking for the strings you marked as translatable and to create or update the translation files <app>.ts. Using Linguist or external tools you can then translate the strings. lrelease compiles these translations from *.ts into *.qm. Only *.qml files will be deployed to your device)

I found out that the default configuration doesn’t work on Android and iOS – please use the executable from …/5.8/clang_64/bin:

(similar screenshots from 5.7)

Test if Linguist will start. From External Tools

Linguist should start:

it’s a good idea to use a shortcut:

Verify Installation: Gallery Qt Quick Controls 2

As last step verify if all is correct configured.

Best way to do this and to get a first impression of new QtQuick Controls 2 is to run the Quick Controls 2 Gallery App.

From Overview – Examples search for “Gallery” and select the right one:

Configure your project for Android / iOS. Even if you only develop mobile apps it’s a good idea also to check the ‘Desktop’. Most mobile apps also run on OSX and the build-run-cycle is much faster- (Thx @jpnurmi for this tip – saved me much time)

Now run on your device(s).

Select your Device – here’s my BlackBerry PRIV (Android 6.0.1):

… and the Gallery App is running:

Congrats – you have installed Qt 5.8. Now you can try out all the new Controls.

Patches / Bugs

ATTENTION: There’s a critical bug using some controls on Android 6 or Android 7: QTBUG-59026

Also there’s a bug with Ripple Effect in Drawer on Android and iOS: QTBUG-59293

Fortunately Qt is Open Source 🙂 With some help by @jpnurmi here are some patches to make it run:

just approved 2016-10-25 16:27 – can take a moment to be visible in App Store

Amazon Fire OS or BlackBerry10 on Amazon App Store:

Sorry – not enough time yet to also develop a native BlackBerry 10 App – hopefully for the next conference. Native BlackBerry 10 Cascades App loads faster and runs smoother on BlackBerry 10.

Also working on Windows 10 Mobile – runs in development mode on Lumia and others – haven’t finished the work to upload release to windows store yet.

You probably know that last years I always developed the BlackBerry 10 App for Eclipse Conferences. This year first I did it for Android and iOS using Qt 5.7 and brandnew Qt Quick Controls 2. Used Qt Quick Controls 2 and Google Material Style. To make my work easier, Entities (Session, Speaker, Track, Room, Conference, …) are generated using a Xtext / Xtend DSL. Started this DSL 2 years ago for BlackBerry 10 Cascades / Qt 4.8 and now I’m able also to generate code for Qt 5.7 / Qt Quick Controls 2. Hopefully at the end of year mobaDSL will be available Open Source.