Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

How to add aar Android libraries?



  • I need to use Google Firebase. After installing the Android SDK, it appears on the extras directories like a various aar files.

    After reading [http://doc.qt.io/qt-5/android3rdpartylibs.html](link url), I've created a project.properties file and put these inside:

    android.library.reference.1=support-annotations/
    android.library.reference.2=support-v4/
    android.library.reference.3=play-services-basement/
    android.library.reference.4=play-services-tasks/
    android.library.reference.5=play-services-base/
    android.library.reference.6=firebase-auth-module/
    android.library.reference.7=firebase-common/
    android.library.reference.8=firebase-auth-common/
    

    In every of these directories, I've unzipped the aar file.

    When compile the QT project, the APK generated doesn't contains any of these files, and the application crash because can't found required classes.



  • Do you have "Use Gradle" checked under Projects > Build > Build Android APK settings?

    I had a similar issue and that ended up resolving it for me. When I switched to a newer Qt version, I had to re-check that setting and it found the classes as expected.



  • @Carmoneer Yes, it's checked.
    Please, could you put your project.properties and show how is your tree directory? and, on the library directory, have you unzipped the aar? Have you put anything on the pro file?



  • I don't know how much this will help you. My project was working with straight lib project folders, not .aar files. Since you unpacked the .aar files, they should have a similar structure as a lib project folder. You'll likely have to do some tweaking/trail & error to get it to work. Below is the basis of how I was able to get it work.

    Note(): There is likely a less kludgy way of doing this, but this I found to work on Qt 5.6.0 and haven't looked back.

    ProjectFolder
    +-cppClassFolders
    +-... 
    +-android
     |  +-bin
     |  +-...
     |  +-libs <-- did not work when placing project lib folder itself  in 'libs' folder
     |     +-.jarFiles
     |  +-src   
     |     +-com/my/app
     |     |  +-main.java
     |     +-myLib   <-- lib project folder(s) inside src
     |     |  +-src/main
     |     |     +-java/com/app
     |     |     |  +-.java files
     |     |     +-res
     |     |     |  +-res files
     |     |     +-AndroidManifest.xml
     |     |  +-build.gradle
     |  +-AndroidManifest.xml
     |  +-build.gradle
     |  +-project.properties
    +-myApp.pro
    
    project.properties
    --------------------
    # Project target.
    target=android-19
    android.library.reference.1=src/myLib/
    
    PRO File
    --------------------
    Nothing added to .pro file pertaining to the lib project folder added.
    

    This isn't exactly the issue your facing, but hopefully this helps to steer you in the right direction. Take care and good luck!



  • Finally it worked for me modifying the build.gradle file and simply adding the dependencie:

    dependencies {
    compile fileTree(dir: 'libs', include: ['*.jar'])
    compile 'com.google.firebase:firebase-auth:9.2.0'
    }

    Also, I've deleted the directories referenced on the project.properties and the project.properties file. Thanks a lot!!


Log in to reply