Does Firebase's "Crash Reports" report automatically on a crash? - android

Let's say I have this:
String x = i;
and i is null, and then, I get a NullPointerException. I didn't add any Firebase Logs, so will this be reported? I've setup the SDK and everything, however, when I tried, it didn't report anything, but it says reports may take up to 24 hours. So, will it be reported?

As per Firebase doc to Create your first error answer is Yes
Firebase Crash Reporting automatically generates reports for fatal errors (or uncaught exceptions).
But Make sure you follow below steps for Set up Crash Reporting for your app:
If you haven’t already, set up Firebase for your Android project.
In the Firebase console, add your app to your Firebase project.
Add the dependency for Crash Reporting to your app-level build.gradle file:
compile 'com.google.firebase:firebase-crash:9.4.0'
Before proceeding, check if your app manifest defines an Application object. If that is the case, check the Known issues section.
I hope its helps you.

Related

E/FirebaseCrashlytics: Failed to retrieve settings from https://firebase-settings.crashlytics.com/spi/v2/platforms/android/gmp/XXXX/settings

I tried new Firebase Crashlytics SDk after migrating from Fabric and seem to run into a weird issue.
Crash logs are not captured in dashboard after upgrading firebase-crashlytics to 17.0.0 and I get this error in log:
E/FirebaseCrashlytics: Failed to retrieve settings from https://firebase-settings.crashlytics.com/spi/v2/platforms/android/gmp/XXXX/settings
and I followed all instructions from firebase console quickstart guide. Please help me if any one have faced similar issue.
In my case, I had migrated the release version but I guess I never enabled Crashlytics on the Firebase console for the debug variant.
A simple mistake, but putting it here in case it helps out someone else.
If you enabled multiple apps in single project, ensure you choose the correct one (left drop down menu choose the correct project which hold the multiple apps, right drop down menu choose the correct running app). I made such mistake and keep looking on the wrong app page and enabling Crashlytics on the wrong app and of course I get that error "Failed to retrieve settings from https://...:
In my case, There was a legacy firebase project which using same package name of app. When I deleted legacy firebase project and It's works like a charm!
Firebaser here -
We often see these kinds of errors after upgrading due to some sort of configuration error when you were switching out your dependencies. Did you make sure to follow all the steps in this guide?
You may also want to enable Crashlytics debug logging and force a test crash to see if the logs give you any other output. And it may help to edit your original question with your Gradle files and any other relevant Crashlytics setup.
Same problem here with 17.2.1, one of my app flavours didnt't work throwing above error. Removing current apps and re-adding them in firebase project settings solved the problem for me.
We had an issue with the firebase apps and had to re-create the android app on firebase. This meant I had to update the google-services.json file.
After doing this, firebase remote config worked but analytics and crashlytics did not.
Turns out android studio was using-an auto generated file values.xml. This contained
<string name="google_app_id" translatable="false">1:xxxxxxx:android:yyyyyyyy</string>
The yyyyyy part of it was still using the old value from the previous google-services.json file. Deleting this file for all flavors, debug and release builds, coupled with an invalidate caches + restart
might do the trick, but just to be safe, what fixed it for me was:
commenting all the firebase libs from all gradle files
syncing gradle
project will not compile at this points since it cant find Firebase dependencies
invalidate caches + restart
uncomment firebase libs in all gradle files
sync gradle
run app and check if firebase crashlytics works
I am using Android studio 4.1.2
If you have changed the google-services.json file, i.e changed it with a one from a different project, you should do the following:
Comment out all the crashlytics dependencies in the gradle files
Build the app
Invalidate cache and restart
Uncomment crashlytics dependencies and rebuild app
This should fix the problem if it's caused by cached values from the previous json file for crashlytics.

After migration from Fabric to FirebaseCrashlytics tests failing

Recently we attempted to migrate from Fabric.io to FirebaseCrashlytics. Followed steps as described in documentation https://firebase.google.com/docs/crashlytics/upgrade-sdk?platform=android
Updated google-service.json files
Replaced fabric.io dependencies with Firebase Crashlytics
Updated code and enabled collection only when prod builds with setCrashlyticsCollectionEnabled(!BuildConfig.DEBUG)
Updated proguard rules
After that, we try to run our test suite when we noticed that it is taking much longer than usual and in the end it failed with many tests reporting OutOfMemoryError. This set of tests run just fine with Fabric dependencies.
Does anybody had or run into a similar problem?
Documentation says Fabric Crashlytics SDK uses a ContentProvider to initialize itself. So it is too late call setCrashlyticsCollectionEnabled function in your Application Code.
Fabric's API key is no longer used by the new SDK. Instead, Crashlytics now uses your app’s google-services.json file to associate your app with your Firebase project and retain your historic crash data. If you have an io.fabric.ApiKey declared in your AndroidManifest.xml file, remove it.
If you want to disable automatic crash reporting and enable it only
for select users, use the Android meta-data tag in your
AndroidManifest.xml file. Then, you can enable crash reporting using
the new setCrashlyticsCollectionEnabled instance method.
https://firebase.google.com/docs/crashlytics/upgrade-sdk?platform=android#firebaseno_longer_works_with_the_fabric_sdk
So you need to disable data collection in your manifest. In order to do that you need to add firebase_crashlytics_collection_enabled meta-tag to your manifest.
<meta-data
android:name="firebase_crashlytics_collection_enabled"
android:value="false" />
https://github.com/firebase/firebase-android-sdk/blob/5440af41f0d15ff1358038dc31fcd1d4eac0a89c/firebase-crashlytics/src/main/java/com/google/firebase/crashlytics/internal/common/DataCollectionArbiter.java#L74
You might want to inject build variables to manifest file since you only want to disable Crashlytics in your test builds. See the link down below.
https://developer.android.com/studio/build/manifest-build-variables.html
OK, I do have update on this. We just updated libraries to latest version that was recently published and issue looks to be sorted
com.google.firebase:firebase-crashlytics-gradle:2.2.0 instead of 2.1.0
com.google.firebase:firebase-crashlytics:17.1.0 instead of 17.0.0
which original article was published with

Problem with adding Firebase Crashlytics in Xamarin Android project

I have some problem with adding Firebase Crashlytics in Xamarin Android project.
I created an empty android project in visual studio. Then I registered the application in google firebase console. Then downloaded google-services.json and put it in the project.
for this file set the build in googleservicejson mode.
Before that, I added the following nugget packages:
Xamarin.Android.Crashlytics
Xamarin.Android.Crashlytics.Answers
Xamarin.Android.Crashlytics.Beta
Xamarin.Android.Crashlytics.Core
In OnCreate method, I added the following code:
Fabric.Fabric.With (this, new Crashlytics.Crashlytics ());
Crashlytics.Crashlytics.HandleManagedExceptions ();
Also I add this meta data in AndroidManifest.xml
<meta-data android:name="io.fabric.ApiKey" android:value="firebase api key" />
Then I added this in strings.xml
<string name="com.crashlytics.android.home.firebaseandroid">33</string>
where home.firebaseandroid is my apk name
After cleaning and rebuild, when I launch the application it throw this exception:
Fabric.Services.Concurrency.UnmetDependencyException: 'This app relies on Crashlytics. Please sign up for access at https://fabric.io/sign_up,
install an Android build tool and ask a team member to invite you to this app's organization.'
As I understand, the application is looking for an api key for the Fabric, but I only have the api key from firebase.
Has anyone had a same problem?
Advise in what direction to look, please.
Thanks in advance.
If you're using a google services file, then you should not be specifying API keys in your AndroidManifest. The google services file already contains the API key that Crashlytics SDK is looking for.
If you want to try something else, see my comment on this issue here: https://github.com/xamarin/XamarinComponents/issues/760#issuecomment-579010612
This is the workaround I've found at that time (yes, I know it is not the last version, please keep reading):
I've fixed the issue at least for me. It seems that the issue was caused by
dependency interactions.
For anybody struggling with this, I've got it working by using exactly
the following versions:
Xamarin.Android.Crashlytics 2.9.4.1
Xamarin.Android.Crashlytics.Answers 1.4.2
Xamarin.Android.Crashlytics.Beta 1.2.9
Xamarin.Android.Crashlytics.Core 2.6.3 Xamarin.Android.Fabric 1.4.3
Xamarin.Build.Download 0.4.11
Installing Crashlytics will install Xamarin.Build.Download 0.7.1 as a
dependency, but (at least for me) it is not possible to get a proper
build anymore with that version. So this package should be downgraded
after it is installed.
Having said that; you must be aware of the imminent deprecation of this Crashlytics version based on Fabric, right?
All of us were received a mail from Google informing that:
We are writing to let you know that the Fabric Crashlytics SDK is now deprecated and will continue reporting your app's crashes until
November 15, 2020. After this date, the Fabric Crashlytics SDK and
beta versions of the Firebase Crashlytics SDK will stop sending crash
reports for your app.What happened?
We are replacing Fabric Crashlytics SDKs and beta versions of the Firebase Crashlytics SDKs with the generally available Firebase
Crashlytics SDKs.What's Next?
To continue getting crash reports in the Firebase console, make sure to upgrade your apps to the Firebase Crashlytics SDK versions
17.0.0+ for Android, 4.0.0+ for iOS, and 6.15.0+ for Unity before November 15, 2020.Android
So everything is going to change soon, and you shouldn't use the Fabric solution anymore, especially for new projects.
You can found the new official nuget package here, but it is a preview (the xamarin team is working on this, I guess, but they are dangerously near the deadline -as we all):
https://www.nuget.org/packages/Xamarin.Firebase.Crashlytics/117.0.0-preview02
This is the official repository issue to add comments:
https://github.com/xamarin/XamarinComponents/issues/956
I'm currently migrating my project to this new Crashlytics version, and one thing to keep in mind is that you need to use AndroidX (that was a problem for me, I'm working on an old project's maintenance, and the migration to AndroidX is not ready yet)
When you'll add this new package and the google-services.json you will need to change the following in your old code:
Every CrashLytics.Crashlytics reference will be just FirebaseCrashlytics.
No initialization is needed, you can get the FirebaseCrashlytics.Instance anywhere
To log an exception you will need to use the RecordException method instead of the old LogException
SetUserIdentifier is changed to SetUserId, and SetUserName is no longer there
There is no method to crash on purpose anymore, so now you have to simply throw any exception you want if you wanna test your implementation
Maybe I'm missing something, but basically, that's all.

Firebase Analytics Won't StreamView

I'm scratching my head a few hours now over this "problem". It should be so simple.
I want to add simple firebase analytics library to my existing android project.
What I did:
Included dependencies in my build.gradle (com.google.firebase:firebase-core:10.0.1)
Applied google services plugin after dependecies bracket
in onCreate of my MainActivity called the following code:
FirebaseAnalytics.getInstance(this).setCurrentScreen(this, "Main Activity", null).
At this point as I understand the streamview in my console should be showing 1 user in the last 30 minutes. But I get 0 users. no activity detected.
I've made sure that google-services.JSON file is included in the project (Android Studio compiles without warnings) and that the package name is the same everywhere (build.gradle, manifest, firebase console).
Also, I've tried sample project from GitHub and it also won't work (detect any activity in the last 30 minutes).
I'm primarily a programmer working in Unity and I didn't have any problems there -setting up the firebase SDK.
But I'm sure I'm still missing something.. so any help would be appreciated.
Thanks!

Android client FirebaseApp initialization error

I had GCM implemented and I am trying to import GCM to FCM now. I dont want to use google-services.json because I want to use different google projects for different environments(Dev, Stag, Prod).
I tried to initialize the app via this code below
FirebaseOptions.Builder options=new FirebaseOptions.Builder();
options.setGcmSenderId("<<project id>>");
options.setApplicationId("<<Project name>>");
FirebaseApp firebaseApp = FirebaseApp.initializeApp(getApplicationContext(),options.build(),"MyTestFCM");
String refreshedToken= FirebaseInstanceId.getInstance(firebaseApp).getToken();
I keep getting exception on Firebase App initialization
Caused by: java.lang.IllegalStateException: FirebaseApp with name [DEFAULT] doesn't exist. Available app names: MyTestFCM
If I remove the app name then i dont get a token back, then when I re-run the application I get a token. I have tried to execute the above piece of code from Mainactivity and Application class. In both places I get the same error.
So my question is how do I initialize Firebase application without using google-services.json
Thanks,
P
Firebase SDK requires to have a "default" project configured via google-services.json
Once you have that you can register FCM sdk with other sender-id using the FirebaseInstanceId.getInstance(context).getToken(...)
But please note that the most recent FCM features (auto-retry of the registration, topic subscriptions) only work with the default project.
So turns out that you need to use google-services.json for FCM, and to handle multiple build variants situation,
Generate respective google-services.json from the firebase console for the different build variants.
Download the google-services.json
In your project create folders for the variants, for example if you want release build, create a folder with name "release" and place the google-services.json in it.
When the app builds, depending upon the build variant it looks for google-services.json in the respective folder and picks up the project details from it.
More details can be found on this thread
google services issues 54
Thanks Arthur Thompson
have you checked to make sure to set your FIREBASE_URL to the right string? Also did you make sure to have the appropriate app setup config?
Last time this happened, I needed to set up my Android App Configs.
https://support.google.com/firebase/answer/7015592
Afterwards, you can follow this setup.
https://firebase.google.com/docs/cloud-messaging/android/client
Please do double check, you added
apply plugin: 'com.google.gms.google-services'
at the bottom of app's gradle file and then clean and rebuild the project

Categories

Resources