How/when to modify AndroidManifest.xml for commandline build?

  • I'm building an Android apk using qmake, make & androiddeployqt (all build scripted; I'm not using Qt Creator). It works good, but there are some configuration "app metadata" things I want to do (like locking orientation to landscape mode) which apparently need me to edit AndroidManifest.xml. Thing is, the first time I ever see an AndroidManifest.xml is when androiddeployqt creates a couple of them in the deployment target folder (one in the folder, another apparently identical one in the bin/ subdir)... and then there's one baked into the .apk when it's done.

    At what point am I supposed to make modifications to the AndroidManifest.xml file? If I copied one into the target deployment folder before androiddeployqt ran, would it respect it? Or is the idea to edit the file in the apk somehow?

    I'm a bit more used to the iOS system where I get a chance to mess with the Info.plist file, in it between the make -spec macx-xcode (which I think creates one) and the macdeployqt. In the Mac world, there's a PListBuddy tool for modifying .plist files (although I used to resort to sed in my build scripts before I discovered that); any equivalent supposed to be used for modifying Android manifests?

  • Aha... just found mention of ANDROID_PACKAGE_SOURCE_DIR in ... says androiddeployqt will copy an AndroidManifest.xml from there... will give it a try.

  • OK, in my app's .pro file, for android builds ANDROID_PACKAGE_SOURCE_DIR points at a folder where my build script does:

        cp ${QTDIR}/src/android/templates/AndroidManifest.xml .
        sed 's|android:screenOrientation="unspecified"|android:screenOrientation="sensorLandscape"|' < AndroidManifest.xml > AndroidManifest.xml.tmp
        mv AndroidManifest.xml.tmp AndroidManifest.xml
        sed 's|"org.qtproject.example"|"int_.myorg.myapp"|' < AndroidManifest.xml > AndroidManifest.xml.tmp
        mv AndroidManifest.xml.tmp AndroidManifest.xml
        sed 's|"-- %%INSERT_APP_NAME%% --"|"My Application Name"|' < AndroidManifest.xml > AndroidManifest.xml.tmp  # But don't override %%INSERT_APP_LIB_NAME%%!
        mv AndroidManifest.xml.tmp AndroidManifest.xml

    (The int_ is bit obscure... but int.myorg.myapp really doesn't work; see !)

    ...and that gets me an application which is landscape locked, displays "My Application Name" to the user, and which creates a data area int_.myorg.myapp.

    Next step is to figure out how to provide an icon.

Log in to reply

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.