[Qbs] AAR dependency for APK generation

Christian Gagneraud chgans at gmail.com
Fri May 22 04:10:23 CEST 2020


On Fri, 22 May 2020 at 03:26, Raphael Cotty <raphael.cotty at gmail.com> wrote:
> Hi,
> qbs runs androiddeployqt with "--aux-mode" argument which disables the use of gradle.
> In this mode androiddeployqt only gathers dependencies.
> The rest of the job being made by qbs.
> So when you use androiddeployqt directly I guess it's without "--aux-mode".
> I could not find much information about what needs to be done to "merge" the AAR package with the apk.
> If anyone has some detailed info we can see how difficult that could be to add the feature in qbs.
> Raph

Hi Raph,

Here are generic info about AAR, not very useful IMHO.
https://developer.android.com/studio/projects/android-library

androiddeployqt is a single cpp file (!):
https://github.com/qt/qtbase/blob/dev/src/tools/androiddeployqt/main.cpp
Couldn't find anything related to aar, i think the magic happens in gradle

We currently generate APK via androiddeployqt with CMake.
Nothing fancy, we generate androiddeploqt.json an have an android manifest file.
That's all: no gradle, no '.properties' file.

>From our log files, it seems that adq copies recursively the
android-package-source-directory, in our case, this means 2 files:
AndroidManifest.xml and libs/neon-platform-sdk-0.1.25.aar

Going throug adq and gradle logs, I can see:

[2020-05-21T12:04:57.166Z] Loading library manifest
/home/gradle/caches/transforms-1/files-1.1/neon-platform-sdk-0.1.25.aar/37691ba971bd8203bd9bfea5ceeaf89b/AndroidManifest.xml
[2020-05-21T12:04:57.166Z] Merging main manifest
/home/jenkins/workspace/NEON_Jenkins_neon-testapp_master/builds/armv7-android/sources/TestApp/AndroidManifest.xml
[2020-05-21T12:04:57.166Z]
[2020-05-21T12:04:57.166Z] Merging library manifest
/home/gradle/caches/transforms-1/files-1.1/neon-platform-sdk-0.1.25.aar/37691ba971bd8203bd9bfea5ceeaf89b/AndroidManifest.xml
[2020-05-21T12:04:57.166Z] Merging manifest with lower
[neon-platform-sdk-0.1.25.aar] AndroidManifest.xml:2:1-4:12
[2020-05-21T12:04:57.166Z] Merging result: SUCCESS

The manifest in AAR is just
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="neon.library">
</manifest>


later on, beside libs/Qt*.jar processing:

[2020-05-21T12:04:57.168Z] Jar input
/home/gradle/caches/transforms-1/files-1.1/neon-platform-sdk-0.1.25.aar/37691ba971bd8203bd9bfea5ceeaf89b/jars/classes.jar
[2020-05-21T12:04:57.168Z] Dexing
/home/gradle/caches/transforms-1/files-1.1/neon-platform-sdk-0.1.25.aar/37691ba971bd8203bd9bfea5ceeaf89b/jars/classes.jar
...
[2020-05-21T12:04:57.168Z] Dexing
'/home/gradle/caches/transforms-1/files-1.1/neon-platform-sdk-0.1.25.aar/37691ba971bd8203bd9bfea5ceeaf89b/jars/classes.jar'
to 'file:/home/jenkins/workspace/NEON_Jenkins_neon-testapp_master/builds/armv7-android/sources/TestApp/build/intermediates/transforms/dexBuilder/release/12.jar'
[2020-05-21T12:04:57.168Z] Dexing
'/home/gradle/caches/transforms-1/files-1.1/neon-platform-sdk-0.1.25.aar/37691ba971bd8203bd9bfea5ceeaf89b/jars/classes.jar'
to 'file:/home/jenkins/workspace/NEON_Jenkins_neon-testapp_master/builds/armv7-android/sources/TestApp/build/intermediates/transforms/dexBuilder/release/13.jar'
[2020-05-21T12:04:57.169Z] Dexing
'/home/gradle/caches/transforms-1/files-1.1/neon-platform-sdk-0.1.25.aar/37691ba971bd8203bd9bfea5ceeaf89b/jars/classes.jar'
to 'file:/home/jenkins/workspace/NEON_Jenkins_neon-testapp_master/builds/armv7-android/sources/TestApp/build/intermediates/transforms/dexBuilder/release/14.jar'
[2020-05-21T12:04:57.169Z] Dexing
'/home/gradle/caches/transforms-1/files-1.1/neon-platform-sdk-0.1.25.aar/37691ba971bd8203bd9bfea5ceeaf89b/jars/classes.jar'
to 'file:/home/jenkins/workspace/NEON_Jenkins_neon-testapp_master/builds/armv7-android/sources/TestApp/build/intermediates/transforms/dexBuilder/release/15.jar'

I don't know why this is done 4 times again.

The AAR is a zip file:
res/
 values/
  colors.xml
  strings.xml
AndroidManifest.xml
R.txt
classes.jar

The above log bits are the only references to AAR i could find.

So it seems that this AAR should be unzipped and somehow merged with
project's res, assets, manifest, .. and processed like a "java.jar"
input.

Chris


More information about the Qbs mailing list