Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

QtFirebase hard for use in project #48

Open
TechComet opened this issue Oct 5, 2017 · 9 comments
Open

QtFirebase hard for use in project #48

TechComet opened this issue Oct 5, 2017 · 9 comments

Comments

@TechComet
Copy link

QtFirebase hard for use in project

@dtyugin
Copy link
Contributor

dtyugin commented Oct 5, 2017

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

@dtyugin
Copy link
Contributor

dtyugin commented Oct 5, 2017

By the way you are welcome to make it better)

@larpon
Copy link
Owner

larpon commented Oct 6, 2017

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!

@rmallah
Copy link

rmallah commented Dec 12, 2017

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

@larpon
Copy link
Owner

larpon commented Dec 12, 2017

@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

@ahmetcumhurarslan
Copy link

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.

@larpon
Copy link
Owner

larpon commented Feb 25, 2020

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

@davidzwa
Copy link

@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.

@larpon
Copy link
Owner

larpon commented Jul 25, 2020

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

6 participants