Is it required to add Firebase Analytics to build.gradle? - firebase

I am following the instructions here to add Firebase to my Flutter project. I want to use Firebase Analytics so I added it in pubspec.yaml
The package page for Firebase Analytics does not mention anything about adding Analytics as a dependency in android/app/build.gradle
No such thing is mentioned in Firebase for Flutter page either which I linked earlier. Now when registering the app in Firebase Console, it asks to add implementation of Firebase Analytics in app level build.gradle
So do I need to add it or not as it looks like only Firebase Console wants me to add it but couldn't find any mention of it on any official Flutter page.

I had the same question as well. Is seems obvious, that you should add the dependency on com.google.firebase:firebase-analytics to your project.
But… You actually don't need it.
It's easy to test! Just set up the Firebase Analytics like it is described in the docs:
google-services.json
apply plugin: 'com.google.gms.google-services' (and related things)
Configure multidex
firebase_analytics: ^X.Y.Z in pubspec.yaml
Don't add any Firebase dependencies to you app/build.gradle!
Now, enable the DebugView in Firebase Analytics: adb shell setprop debug.firebase.analytics.app your.package.
Run the app and send some events. Open the DebugView in Firebase Analytics console and you'll see them all!
Probably, all the magic happens in the Google Services Gradle Plugin:
The google-services plugin has two main functions:
Add dependencies for basic libraries required for the services you have enabled. …
You can see the result of this step by running ./gradlew :app:dependencies.
So, the plugin seems to add them for you!
You could also check what dependencies will be autoconfigured, by running ./gradlew :projects from your android dir. Mine is:
Root project 'android'
+--- Project ':app'
+--- Project ':firebase_analytics'
\--- Project ':firebase_core'
Now, after I add firebase_auth to my pubspec.yml and run flutter pub get, this command indeed lists one extra project:
Root project 'android'
+--- Project ':app'
+--- Project ':firebase_analytics'
+--- Project ':firebase_auth'
\--- Project ':firebase_core'

Adding the Google Analytics for Firebase SDK in your app and enabling analytics settings in the Firebase console is optional. It depends on what Firebase product you will be using. If Firebase suggests you add the Analytics SDK, it means that the Firebase product has integration with Analytics. See this documentation for your reference.

Related

Firebase Crashlytics IOS SourcePackages not found

I tried setting up Firebase Crashlytics to my React Native project.
I received the following error when I was building the project after I added the build phase script.
Script I added from the firebase guide (can be found here) :
Error:
MY-APP-ABC/SourcePackages/checkouts/firebase-ios-sdk/Crashlytics/run:
No such file or directory
When I look in the folder of MY-APP-ABC, I don't see the SourcePackages folder anywhere.
If you installed firebase using cocoa pods use:
"${PODS_ROOT}/FirebaseCrashlytics/run"
If you installed firebase using Swift Package Manager use:
"${BUILD_DIR%/Build/*}/SourcePackages/checkouts/firebase-ios-sdk/Crashlytics/run"

Firebase Crashlytics NDK unstripped files

I have an SDK that uses C++ code. The SDK exports 4 different modules in a maven repo that I publish on either a local maven repo or on GitHub packages.
The apps that consume the SDK should be able to use Firebase Crashlytics and get reports of crashes in the native code as well.
The first problem I have is that I need to provide to the Firebase plugin the folders unstrippedNativeLibsDir and strippedNativeLibsDir:
firebaseCrashlytics {
nativeSymbolUploadEnabled true
unstrippedNativeLibsDir "???"
strippedNativeLibsDir "???"
}
If I go to the project where I build the SDK I can see: build/intermediates/merged_native_libs/release and build/intermediates/stripped_native_libs.
Are these the unstripped and stripped folder respectively?
Is there any documentation about what exactly those folders are supposed to contain?
Anyway if I configure the app firebaseCrashlytics to point to these folders I still need to fix another issue.
I get:
Crashlytics could not find NDK build tasks on which to depend. You many need to manually enforce task dependencies
It looks like since I'm building the libs that use the NDK in another project, then the Firebase plugin does not work.
What am I supposed to do?
Is it possible to get the Crashlytics NDK working even if I build the libraries independently with a separate project?
The only way I made it work was to build the libraries along with the app. The libraries were in separate repos anyway but I included them as sub-repositories in the app.
In this way, you solve the issue of not finding NDK build tasks on which to depend.
I know this is not the answer though

Get ERROR - Missing google_app_id, Firebase Analytics disabled

While using google analytics with flutter, Get
Missing google_app_id. Firebase Analytics disabled. See "https://goo
.gl/NAOOOI"
I tried many things but this issue is not gone. I used
"apply plugin: 'com.google.gms.google-services'"
in my android.build.gradle file also.
Edit:
The following instructions are no longer available as they have been replaced with https://firebase.google.com/docs/auth/flutter/start which use the flutterfire configure command to automatically add the needed dependencies.
build.gradle
app/build.gradle
Did you also add in the classpath and implementation parts as per the instructions?
My project was using older version of flutter admob plugin and google-services.json file. The new Admob plugin expects the admob_app_id key-value pair to be present in the json file.
I solved this issue by downloading the new google-services.json file and replacing the old one with the newly downloaded file.
I have just opened the analytics dashboard in the Firebase Console to make sure it is not disabled and found everything is okay, after that I stopped the app and made a fresh run and found that the error gone.

How to integrate firebase in an Ionic project (android/iOS)?

I am reading articles and testing ways to implement analytics and push notifications in my Ionic app using firebase.
My ionic app targets both android and ios platforms, so where do I place the google-services.json firebase file? Do I have to create an 2 apps within firebase if I need to use firebase for android and iOS?
I am reading many articles some of which say root folder, whereas some mention to put it in the apps folder. Some say we have to then update the config.xml to include the foll:
<resource-file src="google-services.json" target="app\google-services.json" />
I have also read that we need to update the gradle file with application and project level dependencies.
I have put the file in platform/android/app folder and things are working correctly now.
I just want to know what is the best practice when using Ionic and Firebase, where do I place the file and what config changes do I have to make?:
For an Ionic android app
For Ionic iOS app
For Ionic app for both android and iOS platforms
Have a look at the documentation of the firebase plugin :
https://github.com/arnesson/cordova-plugin-firebase
For Android, you have the google-services.json file, and for iOS you have the GoogleService-Info.plist file. These files are required by firebase to work on both iOS and Android. You have to place theses files at the same level as config.xml.
This plugin uses a hook (after prepare) that copies the configuration
files to the right place, namely platforms/ios/\/Resources for ios and platforms/android for android.
So you don't need the resource-file directive in your config.xml, since it is copied automatically.
You don't need to edit the build.gradle file, but If you have other google play plugins installed (like maps or admob), the compilation may not work.
Your build may fail if you are installing multiple plugins that use
Google Play Services. This is caused by the plugins installing
different versions of the Google Play Services library. This can be
resolved by installing cordova-android-play-services-gradle-release.
If your build is still failing, you can try installing
cordova-android-firebase-gradle-release. For more info, read the
following comment about locking down the specific versions for play
services and firebase. It is suggested to use + instead of 15.+ to
ensure the correct versions are used.
EDIT : Since you're using cordova-plugin-firebase-analytics and not cordova-plugin-firebase, it seems that they didn't implement any hook to copy the files. You'll have to place these directives in your config.xml :
<platform name="android">
<resource-file src="google-services.json" target="app\google-services.json" />
...
<platform name="ios">
<resource-file src="GoogleService-Info.plist" />
...
Be sure to install cordova-support-google-services

What's difference between Ionic native Firebase vs Firebase-Analytics?

What's difference between:
https://ionicframework.com/docs/native/firebase/
and
https://ionicframework.com/docs/native/firebase-analytics/
I already use "firebase" for push notifications, but I need register pageviews manually, I need use these two plugins?
Ionic 'Native' Firebase and Ionic 'Native' Firebase Analytics are the Ionic wrappers that are "providing a common interface for all plugins and ensuring that native events trigger change detection in Angular". These wrappers can't work without the plugin.
On the other side we have the Cordova Plugins as you can see in the Ionic documentation for installing a plugin.
$ ionic cordova plugin add cordova-plugin-firebase (1)
$ npm install --save #ionic-native/firebase (2)
(1) - The Firebase Cordova Plugin that includes push notifications, event tracking, crash reporting, analytics and more.
(2) - The wrapper that offers you a 'gentle' interface to work with
So you can get everything you need with the Firebase plugin with OR without the Ionic Firebase wrapper.

Resources