Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. Mobile and Embedded
  4. How/when to modify AndroidManifest.xml for commandline build?
QtWS25 Last Chance

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

Scheduled Pinned Locked Moved Solved Mobile and Embedded
3 Posts 1 Posters 2.1k Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • timdayT Offline
    timdayT Offline
    timday
    wrote on last edited by
    #1

    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?

    1 Reply Last reply
    0
    • timdayT Offline
      timdayT Offline
      timday
      wrote on last edited by
      #2

      Aha... just found mention of ANDROID_PACKAGE_SOURCE_DIR in http://doc.qt.io/qt-5/deployment-android.html ... says androiddeployqt will copy an AndroidManifest.xml from there... will give it a try.

      1 Reply Last reply
      0
      • timdayT Offline
        timdayT Offline
        timday
        wrote on last edited by timday
        #3

        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 https://docs.oracle.com/javase/tutorial/java/package/namingpkgs.html !)

        ...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.

        1 Reply Last reply
        0

        • Login

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • Users
        • Groups
        • Search
        • Get Qt Extensions
        • Unsolved