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

Working with Android Studio regressions (mostly gradle)

    XMLWordPrintable

Details

    • Bug
    • Resolution: Unresolved
    • P2: Important
    • None
    • 5.12.0
    • Build System
    • None
    • Android

    Description

      I've been developing Android Apps in Qt since right after support was announced. I took a break and recently found myself trying to do what I used to, but massively frustrated. Qt 5.12 and the recommended modern SDK/NDK/Android Studio versions no longer works to the same degree as they once did. There are several issues, I think all stemming from revisions to gradle that Qt has not tracked.

      My app uses JNI, which means that Android Studio is the best way to write the Java side of things. Android Studio when used with Qt and QtCreator actively works against this.

      I'll just list all the issues here:

      1. Android Studio complains about using the min and target versions in the AndroidManifest.xml This presents as a build error. You are instructed to place these in the build.grade
        The minSdk version should not be declared in the android manifest file. You can move the version from the manifest to the defaultConfig in the build.gradle file.
        
        The targetSdk version should not be declared in the android manifest file. You can move the version from the manifest to the defaultConfig in the build.gradle file.
        
      2. The only way to get auto-completion to work in AS is to open the build.gradle in the build directory, however modifying these files is a bad idea because they are generated/copied. A clean will lose all your changes. This is caused by gradle.properties file only being generated and placed in the build directory. The gradle build system looks for this file automatically, and Qt puts qt5AndroidDir and other settings in it, which is required by the build/Android Studio. Qt should generate the grade.properties file in the source location (next to AndroidManifest.xml) then copy it into the build directory.
      3. Of course moving the versions to the build.gradle will likely break Qt, because it expects the versions to be in the manifest.
      4. On iOS/Apple, XCode's project files are open-able from the build directory and the files are modifiable because there is no copy (apparently). The project references files in their original location so modifying project files modifies the real files.
      5. I get the following error when opening the build.gradle in the source directory.  If there is a gradle.properties file there, I don't get the error.
        Could not get unknown property 'androidCompileSdkVersion' for object of type com.android.build.gradle.internal.dsl.BaseAppModuleExtension.

      I have one more I will file as a separate bug.

      Attachments

        Issue Links

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

          Activity

            People

              rampe Rami Potinkara
              scorp1us Jason Hihn
              Ramon Sadornil Ramon Sadornil (Inactive)
              Votes:
              2 Vote for this issue
              Watchers:
              4 Start watching this issue

              Dates

                Created:
                Updated:

                Gerrit Reviews

                  There are no open Gerrit changes