[Interest] Android: how to add Firebase dependency?

Alexander Dyagilev alervdvcw at gmail.com
Wed Nov 16 14:18:36 CET 2022


Hello,

I would like to use it the same way as in any native Android app not 
using Qt.

I'm trying to add all the required dependencies to build.gradle and 
getting weird errors.

I'm not good in Gradle so any help is appreciated (if this is possible 
at all, because I'm using quite old Qt 5.12.12).

This is build.gradle I have:

buildscript {
     repositories {
         google()
         jcenter()
     }

     dependencies {
         classpath 'com.android.tools.build:gradle:3.2.0'
     }
}

repositories {
     google()
     jcenter()
}

apply plugin: 'com.android.application'

dependencies {
     implementation fileTree(dir: 'libs', include: ['*.jar', '*.aar'])
     implementation 'androidx.appcompat:appcompat:1.0.2'
     implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
     implementation 'androidx.swiperefreshlayout:swiperefreshlayout:1.1.0'
     implementation 'com.google.code.gson:gson:2.7'
     implementation 'com.jakewharton:process-phoenix:2.1.2' // 
https://github.com/JakeWharton/ProcessPhoenix
     implementation 'me.dm7.barcodescanner:zxing:1.9.13' // 
https://github.com/dm77/barcodescanner
}

android {
     compileSdkVersion 30
     buildToolsVersion "30.0.2"

     sourceSets {
         main {
             manifest.srcFile 'AndroidManifest.xml'
             java.srcDirs = [qt5AndroidDir + '/src', 'src', 'java']
             aidl.srcDirs = [qt5AndroidDir + '/src', 'src', 'aidl']
             res.srcDirs = [qt5AndroidDir + '/res', 'res']
             resources.srcDirs = ['src']
             renderscript.srcDirs = ['src']
             assets.srcDirs = ['assets']
             jniLibs.srcDirs = ['libs']
        }
     }

     lintOptions {
         abortOnError false
     }
}

*This is build.gradle this all dependencies I try to add: *

(I've added classpath 'com.google.gms:google-services:4.3.14' to 
dependencies section and apply plugin: 'com.google.gms.google-services' 
line):

buildscript {
     repositories {
         google()
         jcenter()
     }

     dependencies {
         classpath 'com.android.tools.build:gradle:3.2.0'
         classpath 'com.google.gms:google-services:4.3.14'
     }
}

repositories {
     google()
     jcenter()
}

apply plugin: 'com.android.application'
apply plugin: 'com.google.gms.google-services'

dependencies {
     implementation fileTree(dir: 'libs', include: ['*.jar', '*.aar'])
     implementation 'androidx.appcompat:appcompat:1.0.2'
     implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
     implementation 'androidx.swiperefreshlayout:swiperefreshlayout:1.1.0'
     implementation 'com.google.code.gson:gson:2.7'
     implementation 'com.jakewharton:process-phoenix:2.1.2' // 
https://github.com/JakeWharton/ProcessPhoenix
     implementation 'me.dm7.barcodescanner:zxing:1.9.13' // 
https://github.com/dm77/barcodescanner
}

android {
     /*******************************************************
      * The following variables:
      * - androidBuildToolsVersion,
      * - androidCompileSdkVersion
      * - qt5AndroidDir - holds the path to qt android files
      *                   needed to build any Qt application
      *                   on Android.
      *
      * are defined in gradle.properties file. This file is
      * updated by QtCreator and androiddeployqt tools.
      * Changing them manually might break the compilation!
      *******************************************************/

     // Buggy thing: fails to build. Needs to be replaced with actual 
numbers.
     // https://stackoverflow.com/a/46290586/3765267
     /*compileSdkVersion androidCompileSdkVersion.toInteger()
     buildToolsVersion androidBuildToolsVersion*/
     compileSdkVersion 30
     buildToolsVersion "30.0.2"

     sourceSets {
         main {
             manifest.srcFile 'AndroidManifest.xml'
             java.srcDirs = [qt5AndroidDir + '/src', 'src', 'java']
             aidl.srcDirs = [qt5AndroidDir + '/src', 'src', 'aidl']
             res.srcDirs = [qt5AndroidDir + '/res', 'res']
             resources.srcDirs = ['src']
             renderscript.srcDirs = ['src']
             assets.srcDirs = ['assets']
             jniLibs.srcDirs = ['libs']
        }
     }

     lintOptions {
         abortOnError false
     }
}

*I'm getting the following weird error:*

Generating Android Package
   Input file: 
C:/Work/Source/build-fdm-Android_Qt_5_12_12_Clang_armeabi_v7a-Debug/ui/android-libfdm.so-deployment-settings.json
   Output directory: 
C:/Work/Source/build-fdm-Android_Qt_5_12_12_Clang_armeabi_v7a-Debug/ui/android-build/
   Application binary: 
C:/Work/Source/build-fdm-Android_Qt_5_12_12_Clang_armeabi_v7a-Debug/bin/libfdm.so
   Android build platform: android-33
   Install to device: No

FAILURE: Build failed with an exception.

* Where:
Build file 
'C:\Work\Source\build-fdm-Android_Qt_5_12_12_Clang_armeabi_v7a-Debug\ui\android-build\build.gradle' 
line: 18

* What went wrong:
A problem occurred evaluating root project 'android-build'.
 > ASCII

* Try:
Run with --stacktrace option to get the stack trace. Run with --info or 
--debug option to get more log output. Run with --scan to get full insights.

* Get more help at https://help.gradle.org

BUILD FAILED in 3s
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.qt-project.org/pipermail/interest/attachments/20221116/b3ac7b9e/attachment.htm>


More information about the Interest mailing list