contains(TEMPLATE, ".*app"):!build_pass: {

    defineReplace(emitString) {
        return("\"$$replace(1, \\\\, \\\\)\"")
    }

    FILE_CONTENT =  "{"
    FILE_CONTENT += "   \"description\": \"This file is generated by qmake to be read by androiddeployqt and should not be modified by hand.\","

    FILE_CONTENT += "   \"qt\": $$emitString($$[QT_INSTALL_PREFIX]),"

    # Settings from mkspecs/environment
    FILE_CONTENT += "   \"sdk\": $$emitString($$ANDROID_SDK_ROOT),"
    FILE_CONTENT += "   \"sdkBuildToolsRevision\": $$emitString($$ANDROID_SDK_BUILD_TOOLS_REVISION),"

    isEmpty(NDK_ROOT): NDK_ROOT = $$(ANDROID_NDK_ROOT)
    isEmpty(NDK_ROOT): NDK_ROOT = $$DEFAULT_ANDROID_NDK_ROOT
    FILE_CONTENT += "   \"ndk\": $$emitString($$NDK_ROOT),"

    NDK_TOOLCHAIN_PREFIX = $$(ANDROID_NDK_TOOLCHAIN_PREFIX)
    isEmpty(NDK_TOOLCHAIN_PREFIX) {
        equals(ANDROID_TARGET_ARCH, x86): NDK_TOOLCHAIN_PREFIX = x86
        else: equals(ANDROID_TARGET_ARCH, x86_64): NDK_TOOLCHAIN_PREFIX = x86_64
        else: equals(ANDROID_TARGET_ARCH, mips): NDK_TOOLCHAIN_PREFIX = mipsel-linux-android
        else: equals(ANDROID_TARGET_ARCH, mips64): NDK_TOOLCHAIN_PREFIX = mips64el-linux-android
        else: equals(ANDROID_TARGET_ARCH, arm64-v8a): NDK_TOOLCHAIN_PREFIX = aarch64-linux-android
        else: NDK_TOOLCHAIN_PREFIX = arm-linux-androideabi
    }
    FILE_CONTENT += "   \"toolchain-prefix\": $$emitString($$NDK_TOOLCHAIN_PREFIX),"
    FILE_CONTENT += "   \"tool-prefix\": $$emitString($$NDK_TOOLS_PREFIX),"

    NDK_TOOLCHAIN_VERSION = $$(ANDROID_NDK_TOOLCHAIN_VERSION)
    isEmpty(NDK_TOOLCHAIN_VERSION): NDK_TOOLCHAIN_VERSION = $$DEFAULT_ANDROID_NDK_TOOLCHAIN_VERSION
    FILE_CONTENT += "   \"toolchain-version\": $$emitString($$NDK_TOOLCHAIN_VERSION),"

    NDK_HOST = $$(ANDROID_NDK_HOST)
    isEmpty(NDK_HOST): NDK_HOST = $$DEFAULT_ANDROID_NDK_HOST
    FILE_CONTENT += "   \"ndk-host\": $$emitString($$NDK_HOST),"

    ANDROID_TARGET_ARCH = $$(ANDROID_TARGET_ARCH)
    isEmpty(ANDROID_TARGET_ARCH): ANDROID_TARGET_ARCH = $$DEFAULT_ANDROID_TARGET_ARCH
    FILE_CONTENT += "   \"target-architecture\": $$emitString($$ANDROID_TARGET_ARCH),"

    # Explicitly set qt dependencies of application for deployment
    !isEmpty(ANDROID_DEPLOYMENT_DEPENDENCIES): \
        FILE_CONTENT += "   \"deployment-dependencies\": $$emitString($$join(ANDROID_DEPLOYMENT_DEPENDENCIES, ",")),"

    # Explicitly set external dependencies of application for deployment
    !isEmpty(ANDROID_EXTRA_PLUGINS): \
        FILE_CONTENT += "   \"android-extra-plugins\": $$emitString($$join(ANDROID_EXTRA_PLUGINS, ",")),"

    # Android-specific settings of Project
    !isEmpty(ANDROID_PACKAGE_SOURCE_DIR): \
        FILE_CONTENT += "   \"android-package-source-directory\": $$emitString($$ANDROID_PACKAGE_SOURCE_DIR),"

    !isEmpty(ANDROID_EXTRA_LIBS): \
        FILE_CONTENT += "   \"android-extra-libs\": $$emitString($$join(ANDROID_EXTRA_LIBS, ",")),"

    !isEmpty(QML_IMPORT_PATH): \
        FILE_CONTENT += "   \"qml-import-paths\": $$emitString($$join(QML_IMPORT_PATH, ",")),"

    isEmpty(QML_ROOT_PATH): \
        QML_ROOT_PATH = $$_PRO_FILE_PWD_
    FILE_CONTENT += "   \"qml-root-path\": $$emitString($$QML_ROOT_PATH),"

    FILE_CONTENT += "   \"application-binary\": $$emitString($$absolute_path($$DESTDIR, $$OUT_PWD)/$$TARGET)"
    FILE_CONTENT += "}"

    isEmpty(ANDROID_DEPLOYMENT_SETTINGS_FILE): ANDROID_DEPLOYMENT_SETTINGS_FILE = $$OUT_PWD/android-$$TARGET-deployment-settings.json

    write_file($$ANDROID_DEPLOYMENT_SETTINGS_FILE, FILE_CONTENT)|error()
}

