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.
Related
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.
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
Hey so I have recently started developing an app using flutter and I have already coma across a few issues. I'll quickly resume my situation :
My app uses firebase auth and I uses the android studio refactor feature for androidX.
This managed to get me a working application with a login form but no way to fill in the login form because the android API 28 has a bug in that it does not show the keyboard after you higlight the textinput. But for fire auth you need the API level 28 ...
I managed to get around this by using the flutter channel dev.
Now so far everything works login in and registering users with the firebase auth.
Next I want to implement the facebook login and this is where I encountered even more trouble.
I used the https://github.com/roughike/flutter_facebook_login package and followed all the steps and went through the whole configuration on the firebase page and the facebook developer page.
Add the res/strings.xml
Add permission the manifest
Add and the two under the application key in the android manifest
Add "implementation 'com.facebook.android:facebook-login:4.40.0'" under the app level gradle dependencies
Checked the jcenter() in the project level grable repositories
The actual dart code seems fine and the project builds and runs correctly on IOS
I do not get any errors even running flutter in verbose mode. The logcat is also completly empty.
I am at a complete loss it's really starting to feel like flutter is not really stable after all.
Any help would be greatly appreciated.
Thanks
EDIT: This issue seems to be androidX related and should be fixed as soon as this pull request :
https://github.com/roughike/flutter_facebook_login/pull/87/commits/70dec4403710eb4c52a98e035a0a5e7d7f551d76
is merged.
Ok I got it working by copying the repository locally and adding the changes in the aforementioned pull request.
Then in my pubspec file I used the path: key to set the dependency to my local file instead of the official git.
you can also use
git:
url: (url to your fork with the fixes in place)
I had to run flutter clean before rebuilding the app and now everything works.
EDIT A comment has just been added on the pull request thread :
As we are not sure when this will be merged, you can adjust your pubspec.yaml in the meantime:
dependency_overrides:
flutter_facebook_login:
git:
url: https://github.com/yudaprama/flutter_facebook_login
ref: android-x
I tried to use Crashlytics instead of FirebaseCrash Reporting. I added all relevant Libraries: crashlytics, fabric, answer, beta and everything compiled and started properly on my Android device. I'm working with MarmaladeSDK which has no AndroidStudio/gradle integration. I need to add every lib by myself to the build system (jars, Android Manifest, Resources mainly).
I have two issues:
Crashlytics is not started automatically. I had to call
Fabric.with(this, new Crashlytics()); Which aar library is reponsible for starting the crashlytics services?
I got an CrashlyticsMissingDependencyException with the error message:
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.
How does chrashlytics gets the knowledge that Firebase is the new destination and that there is no need to register at the fabric.io website?
I have no idea what apply plugin:'io.fabric' does? Can I mimic this behaviour even without Android studio? My main issue is probably that gradle does some magic which I don't understand and I assume that apply plugin:'io.fabric' could be responsible for that.
I have a working Android app using:
Google Maps (play-services-maps)
Google Location, Activity Recognition, and Places (play-services-location)
Google Analytics (play-services-analytics)
Google Mobile Ads (play-services-ads)
I'm currently using version 8.3.0, everything works fine. I'd like to upgrade to the last version, 9.2.0. When I change the number in the gradle files, Android Studio is unable to find the APIs packages & classes (saying "package XXX does not exist" and "Cannot find symbol class YYY").
I currently have no google-services.json file, do I need it now? I tried without success, probably because I have several modules / submodules, and I don't know where the json file is needed or not.
The problem is that I need a package name to create the JSON file, and I have some library modules, without package name, using Google APIs.
If needed, here is the project structure:
Maybe you did something wrong while upgrading your project. Make sure you follow the correct steps in upgrading. I suggest you to retry the process of upgrading, but make sure you do the correct way. Like in configuring your build and setting up Google play service.
For your question about google-services.json, Google-services.json contains developer credentials and configuration settings, which is needed to verify while connecting with GoogleApiClient. Though your service is working fine without it. But it will only work with your test device, as it is detecting your developer account. And after you releae your app in public, it will not work without the json file. So you need it and don't delete.
sources: What does google-services.json really do?
So, I finally got it: I was using the AutocompletePrediction.getDescription() method, which has simply been removed (and replaced by AutocompletePrediction.getDescription .getFullText()). That call made gradle stops building -_- .
Thanks Google for removing stuff without deprecating it for a while (though the docs says that the method is deprecated: https://developers.google.com/places/android-api/releases)...
I can also confirm that in my case, the google-service.json file is NOT required.