Could anyone please help me in how to use Xamarin.Firebase.iOS.Crashlytics nuget package for Xamarin iOS. I am getting SIGSEGV code error in my code at random places and I am not able to figure out the actual problem.
Have searched a lot regarding how to implement Crashlytics in Xamarin iOS , but I was not able to find any.
Have followed the steps given in the below two links, but I was only able to implement Crashlytics in xcode with the help of these two links.
Link 1 Link 2
not sure if you solved the problem already or not but I will give it a go since this post almost got me to the finish line. And there might be others out there looking for how to do this.
As of late 2018 the Crashlytics is going from Fabric to Firebase this has resulted in a lot of old posts that are not applicable any more.
To get nuGet package to work you will need to do the following:
Head over to the firebase console and create a project. Then add an app input a "bundle ID", this needs to be the same as what you have in your xamarin app. The nick and App Store ID is optional.
You will now get a GoogleService-Info.plist file, download this file. Now comes the the tricky part. To initialize the firebase app you need to create a dummy xCode project with the same bundle identifier as your project to do this:
Make a new xCode project and follow the instructions from firebase
Remember to use the .xcworkspace file to open the project after insatlling the pods.
Compile and run this app on a device in the firebase console you will hopefully see some reaction if everything has worked out correctly.
Now to add this to your visualStudio xamarin app first include the GoogleService-Info.plist to your project and change the build action to "Bundle Resource"
Then add the Xamarin.Firebase.iOS.Core and Xamarin.Firebase.iOS.Crashlytics packages to the iOS project.
Almost there, only two things left to do.
In the AppDelegate.cs file in the FinishedLaunching function add:
Firebase.Core.App.Configure();
Crashlytics.Configure();
Fabric.Fabric.SharedSdk.Debug = true; // To enable debugging
and also remember to add the two namespaces Firebase.Core and Firebase.Crashlytics to the top of the file.
The last step is to run the app witout the debugger as the debugger will eat all the errors.
This should be it.
More info on the crashlytics nuGet see the github page
Edit
2019-08-03: updated link to getting started NuGet
PLEASE CHECK THE COMMENTS
For iOS:
Add GoogleService-Info.plist file to your app project.
Set GoogleService-Info.plist build action behaviour to Bundle Resource by Right-clicking/Build Action.
Add the Xamarin.Firebase.iOS.Core NuGet to your iOS project: https://www.nuget.org/packages/Xamarin.Firebase.iOS.Crashlytics/
Add the following lines of code somewhere in your app, typically in your AppDelegate’s FinishedLaunching method (don't forget to import Firebase.Core and Firebase.Crashlytics namespace):
App.Configure ();
Crashlytics.Configure ();
For Android:
Make sure you have a project set up in the Firebase Developer Console.
Download your project’s file and place it in the folder of your Xamarin.Android project.
Add the Xamarin.Android.Crashlytics NuGet package: https://www.nuget.org/packages/Xamarin.Android.Crashlytics/
Restart your IDE
Add google-services.json to your Xamarin.Android app project.
Set the build action google-services.json to GoogleServicesJson
Create a string resource with the name com.crashlytics.android.build_id. The value can be whatever you want to uniquely identify a particular build with.
Clean and Rebuild your solution.
Fabric.Fabric.With(this, new Crashlytics.Crashlytics());
Crashlytics.Crashlytics.HandleManagedExceptions();
I had recently written a blog for integrating your Xamarin Apps with Firebase Crashlytics where I have gone in detail on how it can be configured which can be found here:
https://medium.com/#hakimgulamali88/firebase-crashlytics-with-xamarin-5421089bb561
There are few steps needed to be performed in order to implement Firebase Crashlytics in Xamarin.
First of all you have to create a dummy project in Xcode with same bundle identifier.
You can follow this https://fabric.io/kits/ios/crashlytics/install , to implement Crashlytics in Xcode.
Now for Xamarin, use the same Bundle Identifier, and in the info.plist file add the below lines
<key>Fabric</key>
<dict>
<key>APIKey</key>
<string>Your api key</string>
<key>Kits</key>
<array>
<dict>
<key>KitInfo</key>
<dict/>
<key>KitName</key>
<string>Crashlytics</string>
</dict>
</array>
</dict>
Now import Fabric and Crashlytics in the AppDelegate , then initialize Fabric instance with:
Fabric.with([Crashlytics.self])
Related
I want to use Remote Config in a application Xamarin.Forms.
I use a blog - Firebase Remote Config in Xamarin Forms
I have a question about the section: Setup Firebase Remote Config.
Quote
We can setup Firebase Remote Config through the Firebase portal https://console.firebase.google.com/project/Your-Firebase-Project/config and it is an easy process because the portal GUI is nice and friendly. To do it, we add a new parameter key and the default value and of course it can be a json (the GUI has a tool to validate the format of the json content). In the example case the key will be Features and the default value a json:
{
"ShowPlayerDetail": false
}
In this case, we setup a key called ShowPlayerDetail to show or not the player detail.
Question:
Where is the JSON file referred to in this section?
Note.
I am currently in a project.
Update-1
Update-2
Update-3
Update-4
Update-5
I have completed the following steps.
Did I do the right thing?
Do my actions correspond to what is described in the blog?
Or do I need to perform Publish changes? (see Pic-4. Result)
Pic-1
Pic-2
Pic-3
Pic-4. Result
You're using an existing Firebase project but there are no apps in your project, please see the Update-4 screenshot .
You could click the iOS or Android icon to add app to your Firebase project, and make sure the Apple bundle ID matches the Bundle identifier in info.plist of your Xamarin.iOS project, the Android package name matches the packagename in AndroidManifest.xml of your Xamarin.Android project. After registering the app, you can download the google-services.json file for Android and the GoogleService-Info.plist file for iOS.
Unity editor version: 2019.3.15f1
Firebase Unity SDK version: firebase_unity_sdk_6.15.2
Additional SDKs im using: Unity IAP, Gamesparks, Ironsource, Facebook, Appsflyer, GameAnalytics
Platform im using the Unity editor on: Windows
Platform im targeting: Android
Scripting Runtime: IL2CPP
Problem
I am getting data on firebase analytics, but I cannot get crashlytics to report anything. Im stuck on this...
Steps to reproduce:
Add the firebase analytics and crashlytics sdks.
Add the google-services.json GoogleService-Info.plist files somewhere in assets folder
Add this code to initialise the firebase
// Use this for initialization
void Start ()
{
// Initialize Firebase
Firebase.FirebaseApp.CheckAndFixDependenciesAsync().ContinueWith(task => {
var dependencyStatus = task.Result;
if (dependencyStatus == Firebase.DependencyStatus.Available)
{
// Create and hold a reference to your FirebaseApp,
// where app is a Firebase.FirebaseApp property of your application class.
// Crashlytics will use the DefaultInstance, as well;
// this ensures that Crashlytics is initialized.
Firebase.FirebaseApp app = Firebase.FirebaseApp.DefaultInstance;
// Set a flag here for indicating that your project is ready to use Firebase.
VisualDebugger.SetText("crashlytics initialised");
}
else
{
UnityEngine.Debug.LogError(System.String.Format(
"Could not resolve all Firebase dependencies: {0}",dependencyStatus));
VisualDebugger.SetText("crashlytics NOT initialised: " + dependencyStatus);
// Firebase Unity SDK is not safe to use here.
}
});
Invoke("IsCrashEnabled", 5f);
}
void IsCrashEnabled()
{
VisualDebugger.AddLine("IsCrashlyticsCollectionEnabled: "+Firebase.Crashlytics.Crashlytics.IsCrashlyticsCollectionEnabled);
}
In order to get the app to run with the facebook sdk installed Ive added these two lines to proguard-user.txt
-keep public class com.facebook.**{public *; }
-keep public class com.facebook.internal.**{ public *; }
and commented out the following lines from mainTemplate.gradle
//implementation 'com.android.support:appcompat-v7:25.3.1' // Facebook.Unity.Editor.AndroidSupportLibraryResolver.addSupportLibraryDependency
//implementation 'com.android.support:customtabs:25.3.1' // Facebook.Unity.Editor.AndroidSupportLibraryResolver.addSupportLibraryDependency
//implementation 'com.android.support:support-v4:25.3.1' // Facebook.Unity.Editor.AndroidSupportLibraryResolver.addSupportLibraryDependency
When I run the app, firebase is initialised successfully. Also Firebase.Crashlytics.Crashlytics.IsCrashlyticsCollectionEnabled returns true.
I crash the app in a number of different ways, then open it again without reinstalling. But no crash reports are sent.
When I watch logcat when starting the app I see this error from firebase each time the app is opened
2020-09-28 16:18:59.332 25773-25847/? E/FirebaseCrashlytics: Failed to retrieve settings from https://firebase-settings.crashlytics.com/spi/v2/platforms/android/gmp/REDACTEDblahblahblah/settings
Update Oct 19, 2020:
Today a developer updated the issue I linked in this answer saying the Firebase team fixed a backend bug last Friday (Oct 16) that was affecting some new Unity Android apps registering w/ Firebase - likely the bug behind your issue. I had already solved the issue in my own project using the below solution, but if you haven't yet updated your project, I recommend running it again and seeing if Crashlytics is working for you now..
I've been dealing with the same issue this week in Unity 2019.4.11f1 - i see the same error message about not being able to retrieve settings, but with my specific project and appIds in the URL.
I found a solution in this Github issue, which suggests the problem is caused by the version of an android library that is a dependency for the Unity Firebase Crashlytics package. My rough understanding is that the firebase-crashlytics-unity library is a wrapper around android library firebase:firebase-crashlytics, and the unity package allows the underlying native Android code to be used from Unity. Version com.google.firebase:firebase-crashlytics:17.10.0 has issues with getting the settings for some Firebase projects on Android. Myself and several others following this issue found forcing Unity to use this specific dependency at version 17.1.1 resolved the issue.
Someone else with the same issue in the thread contacted Firebase support and was told:
The error you are seeing "Failed to retrieve settings" is related to
the SDK version being used. If you go to "Assets > Firebase > Editor>
CrashlyticsDependencies" you can manually update the SDK to point to
the latest Crashlytics SDK version 17.2.2. Please give it a try and if
you continue having issues, let me know.
It turned out this advice wasn't quite right - some of us following the thread then experienced a different issue when using the Android Crashlytics SDK version 17.2.2 with Unity crashlytics version 6.16.0. So I'd specifically recommend trying out the below suggestion or other solutions in the thread to set your Android crashlytics library to v17.1.1.
Changes I made in my project to address this:
First, I updated my unity firebase packages in the package manager to use version 6.16.0. In my project 4 packages were installed - core, analytics, crashlytics, and messaging.
Then I searched for the the Crashlytics package's dependency file - Crashlytics-Dependencies.xml (found by searching project - was in /Library/PackageCache/com.google.firebase.crashlytics#6.16.0/Firebase/Editor/ for me). This file initally had "com.google.firebase:firebase-crashlytics:17.0.0" listed, which I updated to be: "com.google.firebase:firebase-crashlytics:17.1.1".
As an extra precaution, I also added created a MyProject-Dependencies.xml file, as was suggested by a user in the thread - this file also specifies version "com.google.firebase:firebase-crashlytics:17.1.1".
Next, I modified the Unity build process to use a custom mainTemplate.gradle file to specify dependencies,
rather than using the External Dependency Resolver to manage and
embed unity packages (option in Build Settings > PlayerSettings >
Android).
I also updated the settings on the External Dependency Manager Android Ressolver:
Disabled AutoResolve and Disabled Resolve on Build (we dont want EDM updating dependencies without our knowledge when building)
I also turned disabled AndroidPackageInstallationEnabled - this has made the resolution process much faster and removed a bunch of .aar files from the android dependencies list, and hasn't caused any problems in my project.
I then ran External Dependency Resolver > Android > Force Resolve, which after the settings changes above, should now embed a list of the dependencies for the Android build into the mainTemplate.gradle file - Check this file (its in Assets/Plugins/Android) and you should now see com.google.firebase:firebase-crashlytics:17.1.1 in that list.
Also, I recommend reading this article about managing Unity Firebase dependencies from one of the Firebase developer advocates, Patrick Martin. It helped me wrap my head around how Android dependency management in Unity works, as well as how the Android gradle build process works.
I cannot start project with yarn run dev and have this error:
FirebaseError: Analytics: "measurementId" field is empty in Firebase config. Firebase Analytics requires this field to contain a valid measurement ID. (analytics/no-ga-id).
I deleted yarn.lock file, added some extra variables to.env file. Where can I find measurementId? What might help in this kind of error? May be somebody have already faced with such problem. Thanks :)
This has nothing to do with your yarn lock file. Which client side sdk are you using for Firebase? Angularfire perhaps?
I assume you did put your firebase config in your environment file of your angular app. Just add the property "measurementId" to it with the correct value, and you are good to go. You can get this property in your Firebase project.
If your app uses the Firebase hosting and uses reserved URLs you are good to go since it automatically handles the configuration for your application. It seems it isn't your case.
You should add or update the config file to ensure the measurementId field is present. To find the config file go to Your apps card in your Project settings from the Firebase Console.
It can be useful as well: How to get the measurementId from the Firebase config?
i am trying to deploy my project on firebase hosting. And whenever i am using firebase init it is showing error in terminal as "firebaserc already has a default project " and it exit with that error
i have tried firebase logout and firebase login again . And used "firebase use" command also to change the project but it is still performing the firebase init action on the default project
i want to remove that default project
If you look very carefully at the messaging, it's saying that the name of the file is ".firebaserc" with a leading dot. This file indicates that firebase init was already run in this folder, and the contents of that file describe which project it's connected to (flairboat-48f7b). If you no longer want that file, delete it and start over. Since it starts with a dot, it might be hidden from normal view, but you can be sure that it exists.
you should write:
firebase use --add
and it work! You get the option to choose the preject from firebase.
I ran into the same issue.
Due to a small mistake in setting up the project in firebase, I had to delete it.
But later, I realized that my application NEEDS the default project to be hosted from firebase.
Since I found no shortcuts and running out of time, I did "this" to fix the issue in 10 minutes...with a 5-Step-Process. This is not a "Clever tip". But if you want things up and running soon, you can try this...
Create a new project (in my case, it's React project in VS Code IDE) using - npx create-react-app newprojectname to create a new react project with a different file name.(Don't delete or replace your previous project yet... )
While the new project is being created, create a new project in firebase to host your project.
Copy the folder from your old project that has all your work (it's "src" folder in case of React) and replace the "src" folder in the new project you created in your local machine.
Install all dependencies...Don't forget to add any dependencies you added to you old project. Look at the package.json file of the old project and import all dependencies.
Hit the start command (npm start in my case) and see your project running.
*I'll update if I found some firebase secret to resolve this issue. You can look for the same.
Ensure your firebase project support email and firebase initialize login email are same. If different? It won't be worked. so you must ensure it that two email (firebase project support email and firebase initialize email) are same.
I'm trying to use sqlite with sqlcipher for unity ios game.
I get an sqlite unity example https://github.com/takezoux2/unity-orm
I added a method for unity to call function set key:
[DllImport("__Internal", EntryPoint = "sqlite3_key")]
private static extern int sqlite3_key(IntPtr stmHandle, string key, int len);
I compiled sqlcipher to static library (libsqlcipher.a). Add it to Assets/Plugins/iOS with header sqlite3.h, sqlite3ext.h
In Unity editor, it works without encryption. It's ok. I just want encryption work on ios devices.
I keep moving on export Xcode project, config OPENSSL_SRC in Source trees, add C flag -DSQLITE_HAS_CODEC, add search header "sqlcipher", add Security framework then run on device.
It works! There is no issue. I get the database encrypted in Document folder (i tested it with hexdump -C, SQLiteManager)
The problem only occurred after I archive the app to ipa file (using enterprise provisioning profile). I Use iFunbox to install app to device. The app crash immediately on launch.
This is what i get from crash log:
Exception Type: EXC_BAD_ACCESS (SIGABRT)
Exception Subtype: KERN_INVALID_ADDRESS at 0x00000000
I try to replace sqlite3_key with PRAGMA key='123456';
No more crash, everything works but the output database is not encrypted.
I don't know what different between Archive and Build mode. My example works if i build directly to device (with both sqlite3_key and PRAGMA key='123456';), but archive mode does not.
I also try to import sqlcipher xcode project to unity xcode project (remove libsqlcipher.a from Plugins/iOS), set all architectures to armv7 (also try with/without -mno-thumb), add C flag -DSQLITE_HAS_CODEC, add search header "sqlcipher", add Security framework then run directly on device. It work!!!
Then i try to archive app, install app with iFunbox. Again, i get crash on launch.
I'm not sure if i'm setting something wrong with my project (https://github.com/tamhv/unity-orm-with-encrypt). Please someone take a look on this and give me advice. Thank you so much!
I can't tell you why you are crashing, but you can switch your app to Release mode and then debug it to find out.
In XCode, On the top toolbar next to the play/stop button press on the Project name to bring up the context menu and select Edit Schema.
Under Run/Debug change the Build configuration to Release.
Now run the app from XCode and hopefully you'll see the same crash but have a stack trace.