QtFirebase icon indicating copy to clipboard operation
QtFirebase copied to clipboard

QtFirebase hard for use in project

Open TechComet opened this issue 7 years ago • 9 comments

QtFirebase hard for use in project

TechComet avatar Oct 05 '17 14:10 TechComet

What is the problem? Did you take a look at the sample app? https://github.com/Larpon/QtFirebaseExample

dtyugin avatar Oct 05 '17 15:10 dtyugin

By the way you are welcome to make it better)

dtyugin avatar Oct 05 '17 15:10 dtyugin

I agree that the setup process is not optimal. IMHO the most problems lie in how Qt and QMake behaves when setting up 3rd party projects and cross-compilation (it's not straight forward to handle gradle and Info.plist dependencies / content etc. dynamically via QMake). Also the Firebase setup on the different target platforms (Android / iOS) is a little suboptimal in some cases (e.g. the Cloud Messaging where you have to activate certificates etc.).

I'm hoping to get enough time on my hands to try my luck with qbs soon (others are welcome to contribute the foundation for this!). I hope we can skip a lot of the setup steps - and preferably end up just having people provide: google-services.json GoogleService-Info.plist QTFIREBASE_CONFIG

I've also thought about a small GUI application for the actual setup but that's undecided and only "nice to have" at this point.

And as @greenfield932 mentioned: We gladly accept any pull requests with improvements!

larpon avatar Oct 06 '17 08:10 larpon

Today I successfully incorporated Firebase Cloud Messaging service in my Qt App via QtFirebase. Thanks to Everyone who brought it this far.

I followed SETUP.md primarity and I had to do below additional modifications to build.gradle that i am listing below.

  1. had to add applicationId
defaultConfig {
      applicationId "com.domain.apps.appname" // Used by Firebase auto-config                                                                            (the google-services.json from Firebase console)

    }
  1. had to add below
// Pre-experimental Gradle plug-in NDK boilerplate below.
// Right now the Firebase plug-in does not work with the experimental
// Gradle plug-in so we're using ndk-build for the moment.
project.ext {
    // Configure the Firebase C++ SDK location.
    firebase_cpp_sdk_dir = System.getProperty('firebase_cpp_sdk.dir')
    firebaseSdkUsed = 'system property firebase_cpp_sdk.dir'

    if (firebase_cpp_sdk_dir == null || firebase_cpp_sdk_dir.isEmpty()) {
        firebase_cpp_sdk_dir = System.getenv('FIREBASE_CPP_SDK_DIR')
        firebaseSdkUsed = 'system env variable FIREBASE_CPP_SDK_DIR'
        if (firebase_cpp_sdk_dir == null || firebase_cpp_sdk_dir.isEmpty()) {
            if ((new File('firebase_cpp_sdk')).exists()) {
                firebase_cpp_sdk_dir = 'firebase_cpp_sdk'
            } else {
                throw new StopActionException(
                    'firebase_cpp_sdk.dir property or the FIREBASE_CPP_SDK_DIR ' +
                    'environment variable must be set to reference the Firebase C++ ' +
                    'SDK install directory.  This is used to configure static library ' +
                    'and C/C++ include paths for the SDK.'
                )
            }
        }
    }

    if (!(new File(firebase_cpp_sdk_dir)).exists()) {
        throw new StopActionException(
            sprintf('Firebase C++ SDK directory %s does not exist', firebase_cpp_sdk_dir)
        )
    }
    println 'QtFirebase using Firebase C++ SDK located in ' + firebase_cpp_sdk_dir + ' (from ' + firebaseSdkUsed + ')'

    // Check the NDK location using the same configuration options as the
    // experimental Gradle plug-in.
    def ndkDir = android.ndkDirectory
    ndkUsed = 'android.ndkDirectory'

    if (ndkDir == null || !ndkDir.exists()) {
        ndkDir = new File(System.getProperty('ndk_dir'))
        ndkUsed = 'system property ndk_dir'
    }
    if (ndkDir == null || !ndkDir.exists()) {
        ndkDir = new File(System.getenv('ANDROID_NDK_HOME'))
        ndkUsed = 'system env variable ANDROID_NDK_HOME'
    }
    if (ndkDir == null || !ndkDir.exists()) {
        throw new StopActionException(
            'Android NDK directory should be specified using the ndkDir ' +
            'property or ANDROID_NDK_HOME environment variable.'
        )
    }
    println 'QtFirebase (Firebase C++ SDK) using Android NDK located in ' + ndkDir + ' (from ' + ndkUsed + ')'

}


repositories {
    flatDir {
        dirs project.ext.firebase_cpp_sdk_dir + "/libs/android"
    }
}

  1. had to add classpath 'com.google.gms:google-services:3.+' in
buildscript {
    repositories {
        jcenter()
    }

    dependencies {
        classpath 'com.android.tools.build:gradle:2.2.3'
        classpath 'com.google.gms:google-services:3.+'
    }
}

Additional Comments:

  1. regarding
Edit paths to match your setup in /path/to/QtFirebase/src/android/gradle.properties. (Example)
Edit paths to match your setup in /path/to/QtFirebase/src/android/local.properties.(Example)

above files do not exists under QtFirebase , but instead exists in android directory of app. Moreover QtCreator puts note above each file that it should not be modified , as they are autogenerated , eg:

gradle.properties

# This file is automatically generated by QtCreator.
#
# This file must *NOT* be checked into Version Control Systems,
# as it contains information specific to your local configuration.
androidBuildToolsVersion=25.0.2
androidCompileSdkVersion=27
buildDir=.build
qt5AndroidDir=/mnt/khajana/Qt/Qt5.9.2/5.9.2/android_armv7/src/android/java

local.properties

## This file is automatically generated by QtCreator.
#
# This file must *NOT* be checked into Version Control Systems,
# as it contains information specific to your local configuration.

sdk.dir=/mnt/khajana/android/android-sdk-linux

rmallah avatar Dec 12 '17 19:12 rmallah

@rmallah - you're welcome - and thanks for clearifying.

I didn't know about the gradle.properties and local.properties shouldn't be checked in to a VCS.

I'll correct the paths you mention in the documentation - they seem to be wrong.

I often emphasize that people should see how QtFirebaseExample is setup - as the master branch will usually always be working with the master branch of the QtFirebase project. Some of your points are in the Example app.

I will add some better details to SETUP.md about the gradle stuff

larpon avatar Dec 12 '17 19:12 larpon

I agree that the setup process is not optimal. IMHO the most problems lie in how Qt and QMake behaves when setting up 3rd party projects and cross-compilation (it's not straight forward to handle gradle and Info.plist dependencies / content etc. dynamically via QMake). Also the Firebase setup on the different target platforms (Android / iOS) is a little suboptimal in some cases (e.g. the Cloud Messaging where you have to activate certificates etc.).

I'm hoping to get enough time on my hands to try my luck with qbs soon (others are welcome to contribute the foundation for this!). I hope we can skip a lot of the setup steps - and preferably end up just having people provide: google-services.json GoogleService-Info.plist QTFIREBASE_CONFIG

I've also thought about a small GUI application for the actual setup but that's undecided and only "nice to have" at this point.

And as @greenfield932 mentioned: We gladly accept any pull requests with improvements!

a while ego i wrote a GUI which downloads required files, modifies them and creates a template start point using qt firebase. It creates both android and ios according to user specifications. however the structure is changed and as i stated here i could not compile the ios side of the applications. if you decide to go through this "GUI" way of improvement maybe i can help.

ahmetcumhurarslan avatar Feb 07 '20 08:02 ahmetcumhurarslan

@ahmetcumhurarslan thank you! Right now I got my attention on other projects - but I will reach out if I get the time!

larpon avatar Feb 25 '20 19:02 larpon

@ahmetcumhurarslan I am interested in pulling your GUI into this repo, or collab to make this work. I see why and how this is essential and we have the same necessity for using QtFirebase.

davidzwa avatar Jul 11 '20 19:07 davidzwa

See also efforts and discussion in https://github.com/Larpon/QtFirebaseExample/issues/32

larpon avatar Jul 25 '20 13:07 larpon