Uploaded image for project: 'Qt'
  1. Qt
  2. QTBUG-129185

Enable using Android package source dir in Android Studio

    XMLWordPrintable

Details

    • Bug
    • Resolution: Unresolved
    • P2: Important
    • None
    • 6.8.0 Beta4
    • None
    • Android
    • 2025Season1QtforAndroid, 2024wk52FOQtforAndroid

    Description

      We have some Java sources in our project, which our developers prefer to edit in Android Studio. While it’s possible to open the Android package source (/android subfolder) of any Qt project in Android Studio, getting the Android project outline, proper syntax highlighting, and other benefits like this requires Android Studio to be able to compile the Gradle project.

      The default build.gradle file from the Qt templates contain various variables that are only set when building with Qt, which causes Gradle to throw the following error in Android Studio:

      A problem occurred evaluating root project 'android'.
      > Could not get unknown property 'qtGradlePluginType' for root project 'android' of type org.gradle.api.Project.
      

      In the past we were able to work around this by checking whether these variables are available like this:

      android {
        if (project.hasProperty('qtAndroidDir')) {
          // building with Qt
          namespace androidPackageName
          ...
        } else {
          // building with Android Studio
          namespace "com.example.app"
          ...
        }
      }

      However this has been breaking in different ways due to various changes in recent Qt releases (6.7 and 6.8) due to differences in how androiddeployqt and Qt Creator parse this file in order to find the active namespace.

      It would be helpful if this would be officially supported with the default templates.

      Attachments

        Issue Links

          No reviews matched the request. Check your Options in the drop-down menu of this sections header.

          Activity

            People

              qtandroidteam Qt Android Team
              fseiffert Frederik Seiffert
              Votes:
              2 Vote for this issue
              Watchers:
              4 Start watching this issue

              Dates

                Created:
                Updated:

                Gerrit Reviews

                  There are no open Gerrit changes