Using QtCreator on host OSX to cross compile for target Android


This is a log, or instructions.  Disclaimer:

  • things change, this will quickly become outdated.
  • I sometimes make mistakes
  • there may be other ways to do this

This is similar to my post about using Linux host for the same purpose.  Here, I switched to a new host: OSX.  I decided that OSX was a better host than Linux, since OSX supports more targets (OSX, iOS, and Android) whereas Linux only targets (Linux and Android.)

There are only slight differences between using host OSX and host Linux:

  • where menu items live in the QtCreator GUI.
  • how prerequisite third-party tools are packaged

My use case is also using pyqtdeploy.  So in this example, I start with a QtCreator project that pyqtdeploy created for me. You might also use these instructions for a Qt example project.

Prepare tools that QtCreator depends on

QtCreator, to build for Android, requires third-party tools.   Install:

  • Android SDK (Google)
  • Android NDK (Google)
  • Ant (Apache ) (a better ‘make’, that QtCreator uses.)
  • JDK (Oracle)

OLD: Follow widely published instructions.  But …

New: QtCreator is smart enough to help you download these things: choose the download icons (a green arrow pointing down into a tray) in QtCreator>Preferences>Android.


  • a directory e.g. $HOME/android-sdk-macosx
  • a directory e.g. $HOME/android-ndk-r10d
  • a directory e.g. $HOME/apache-ant-1.9.4
  • a scattered installation of the JDK (it comes as an OSX .dmg, or self-installer)

You should not expect any executables to be installed in your PATH, i.e. ‘which ant’ returns nothing.  Or at least you will not be invoking any executables: instead you will configure QtCreator to know where the executables live.

Open a project and configure it with a kit

Here I double-clicked on the .pro file that pyqtdeploy created.  Expect QtCreator to start and show you a dialog asking you to choose a kit.

In my case (probably because of futzing I had done earlier) there were multiple Android kits, including one that apparently I had created earlier.  I chose ‘Android for armeabi-v7a (GCC 4.0, Qt 5.4.0)’, which I think is one that is distributed (not the one I had created earlier.)

I also changed the ‘build directory’ to the one that was specialized with ‘android’ e.g. /Users/bootch/pensoolpyqtdeploy/build-Pensool-Android_for_armeabi_v7a_GCC_4_9_Qt_5_4_0-Debug  (not $HOME/pyqtdeploy/build which is the directory that pyqtdeploy created.)

Choose the ‘OK’ button.  Expect the usual Qt screen showing your open project.

Configure QtCreator Android Tools

Choose QtCreator>Preferences.  Expect a ‘Preferences’ dialog to open.

Select the ‘Android’ item in the left panel.  Expect the right panel to display ‘Android Configurations.’

If you haven’t installed the third-party prerequisites already, you can use the download icons in the right panel.  QtCreator is also smart enough to find some of these prerequisites (the JDK).

In the right panel, click on the ‘Choose’ button beside ‘Android SDK location’.  Expect a file browser to appear.  Navigate to the directory where you installed the Android SDK and choose the OK button.

Repeat for Android NDK and Ant executable (which is in apache-ant-1.9.4/bin/ant).

Running your app

Choose the ‘Run’ icon.  Expect a dialog titled ‘Select Android Device’.

Plug in your Android device to a USB port and power up the device.  Wait for it to boot.  Choose the ‘Refresh Device List’ button.  Expect your device to appear in the list.

Select your device and choose the ‘OK’ button.  Expect Qt progress bar to show ‘Build’.

Expect link errors (at least in my case using pyqtdeploy, I had not properly compiled a static Python?)  Or, if it deploys, expect a mysterious crash (better to use target iOS from this host, since it gives much better crash reports.)



The rest of this is cruft.  If you choose the kit distributed with QtCreator, you won’t need this.  If you choose a kit that you created.

Configure the build settings for a custom kit

At least for me, I needed to configure:

  • the build directory
  • the compiler

Choose the ‘Projects’ icon in the left panel.  Expect it to show a tabbed panel, initially on the ‘Build&Run’ tab.

Expect that tab to have a nested tabbed panel initially displaying one kit ‘Qt5.4.0 for Android armv7’.

Expect that kit to have a toggle button ‘Build/Run’.  Ensure it is toggled to ‘Build’.

Configuring the compiler for the kit

Choose the ‘Manage Kits…’ button to the left of the ‘Qt5.4.0 for Android armv7’ tab.  Expect a ‘Preferences’ dialog to open.

Ensure that ‘Build&Run’ is selected in the left panel.  Expect the right panel to be titled ‘Build&Run’ and to have tabs such as ‘General’, ‘Kits’, etc.

Choose the ‘Compilers’ tab.  Expect the tabbed panel to display a list of  compilers under the heading ‘Auto-detected.’

Select ‘Android GCC(arm-4.9)’ and choose the OK button.






Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s