Uploaded image for project: 'Qt Creator'
  1. Qt Creator
  2. QTCREATORBUG-19077

Android: Using Gradle breaks .pri workflow (No resource found that matches the given name)

    XMLWordPrintable

Details

    • Bug
    • Resolution: Unresolved
    • Not Evaluated
    • None
    • Qt Creator 4.4.1
    • Android Support
    • None

    Description

      I have noticed warnings that ant builds are being deprecated, so I tried migrating to gradle.

      In our source repository we have helper semi-project with.pri to add Google Play Services into Android app:

      3rdparty/Android/Google Play Services/libGooglePlayServices.pri:

       android {
         
          GOOGLEPLAYSERVICES_SRC.path = /
          GOOGLEPLAYSERVICES_SRC.files += $$files($$PWD/android/google-play-services_lib*)
      
          INSTALLS += GOOGLEPLAYSERVICES_SRC
      
          GOOGLEPLAYSERVICES_PROPERTIES.path = /
          GOOGLEPLAYSERVICES_PROPERTIES.target = android-build/project.properties
          GOOGLEPLAYSERVICES_PROPERTIES.commands = echo "android.library.reference.1=google-play-services_lib/" | tee -a $$GOOGLEPLAYSERVICES_PROPERTIES.target
          INSTALLS += GOOGLEPLAYSERVICES_PROPERTIES
      }
      

      In this way, we can include .pri and it will build successfully with this library included.

      But, when migrated to Gradle, I got this error:

      /home/vincas/Desktop/GradleBugReport/build-AndroidGradleTest-Android_for_x86_GCC_4_9_Qt_5_9_2_for_Android_x863-Debug/android-build/build/intermediates/manifests/full/debug/AndroidManifest.xml:149:28-65: AAPT: No resource found that matches the given name (at 'value' with value '@integer/google_play_services_version').
      

      When app's AndroidManifest.xml has this line, referencing value from Google Play Services package:

      <meta-data android:name="com.google.android.gms.version" android:value="@integer/google_play_services_version"/>
      

      Please note, that using ant it worked OK.

      I have tried to workaround by making .pri to install  google-play-services_lib/res/values/version.xml file into res/values, but even if I see log entry of this action, there are no version.xml found in shadow build directory:

      /opt/Qt/5.9.2/android_x86/bin/qmake -install qinstall /home/vincas/Desktop/GradleBugReport/3rdparty/Android/Google\ Play\ Services/android/google-play-services_lib/res/values/version.xml /home/vincas/Desktop/GradleBugReport/build-AndroidGradleTest-Android_for_x86_GCC_4_9_Qt_5_9_2_for_Android_x863-Debug/android-build/res/values/version.xml
      

      So I guess the issue is that this dependesny, is built after processing main AndroidManifest.xml, having res/values cleared, compared to what was happening with ant build system. If I execute that qmake -install qinstall... line after the build, I do see version.xml installed in there.

      If I remove that "@integer/google_play_services_version" reference, it builds successfuly with Gradle too, I can see this Google library inside of .apk.

      The main idea is to use .pri's to extend Android app without "hand work" (as modifying build.gradle, as it already uses "src", "java" as source directories by default), although it looks like I cannot achieve that using Gradle now (without modifying build.gradle that is, or copying version.xml into app's project android/res/value directory).

      I have attached test case to reproduce the issue.

      First, make sure that AndroidGradleTest.pro includes libGooglePlayServices_gradle.pri, and build project with Use Gradle option on. It should fail.

      Secondly, make sure that AndroidGradleTest.pro includes alternative libGooglePlayServices_ant.pri, and uncheck Use Gradle option, delete shadow build directory, and build again. It should succeed.

      Attachments

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

        Activity

          People

            portale Alessandro Portale
            talkless Vincas Dargis
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

              Created:
              Updated:

              Gerrit Reviews

                There are no open Gerrit changes