Android specific setup

March 25, 2020 · View on GitHub

When building QtFirebase for Android targets you need the following extra steps to get everything running.

General

Ensure target device has Google Services apk installed

Make sure you have Google Services apk installed and updated on the target device. Firebase won't work without it. Furthermore the project needs gradle and the Android NDK (>= r10d) to build on Android.

API level

Make sure you set your Android build SDK to, at least, API level 28 in your Qt Creator project settings. Firebase still work on devices from API level 14 according to this source - but it apparently need to be build with a higher target API.

NOTE Your project's API level might need to be higher than we suggest here due to Qt or Google Play requirements. These demands change often.

Gradle setup

Enable gradle in your Qt Creator build options.

For a fully working build.gradle file please refer to this example

Depending on what modules you intend to use from Firebase you should edit the dependencies in your project's gradle.build to match your preferences and app ids. (Example)

Edit paths to match your setup in /path/to/your/Qt Creator/project/android/gradle.properties. (Example)

Edit paths to match your setup in /path/to/your/Qt Creator/project/android/local.properties.(Example)

On some Qt Creator setups the above *.properties files are auto-generated by the build tool - and thus overriden on each build. If you're using qmake you can use ANDROID_PACKAGE_SOURCE_DIR to include your own overrides of these files.

Firebase configuration

Include google-services.json downloaded from the Firebase console. (Example)

Firebase Messaging specific

Note Using Messaging is only possible with Qt 5.9+ due to gradle dependencies that require more recent versions of the Android SDK. Upgrading these will also "force" you to upgrade Qt (because of some bugs in Qt Creator) in order for it all to just work™

To use Messaging on Android there is some additional setup.

You'll need to have recent versions of the Android SDK/NDK toolchain.

Android SDK Build-Tools >= 25.0.0
Android NDK >= r10e

gradle >= 2.3.3 like here

NOTE Qt usually require or advice higher versions than stated here. Go with whatever Qt requires!

Services

Add Messaging specific services to your AndroidManifest.xml file. (Example).