1) I implement firebase crashlytics in my react native project.
2) I used below npm
npm install #react-native-firebase/app#alpha
react-native link #react-native-firebase/app
npm install #react-native-firebase/crashlytics#alpha
react-native link #react-native-firebase/crashlytics
3) I can do crash app by programmatically using
async forceCrash() {
firebase.crashlytics().crash();
await firebase.crashlytics().setAttributes({ something:
"something" });
firebase.crashlytics().log("A woopsie is incoming :(");
firebase.crashlytics().recordError(new Error("Error Log"));
}
but i can't error log report in firabase console.
Please give me your value able suggestion. where i am wrong.
React native is not officially supported but developers have been able to use crashlytics with React native. From your snippet of code, it seems that you are try trying make a test crash and send a non-fatal exception at the same time.
If you want to see logs on your crash report, the code should look something like this:
Crashlytics.log("Crash occurred! Bailing out...");
Make sure that you set these logs before your app crashes.
If you want to send non-fatal exception:
try {
throw new NullPointerException("It is Pointer No-Fatal Error");
} catch (Exception e) {
Crashlytics.logException(e);
// handle your exception here!
}
Logs will also appear with non-fatal exceptions as long as they were set before the exception occurs.
Related
I am out of ideas right now why my app does not pass app check verifications. I am building a React-Native app with Firebase using react-native-firebase. It throws this error:
[firestore/permission-denied]
I have installed the app-check package for react native. I have added these lines to app/build.gradle:
implementation 'com.google.firebase:firebase-appcheck-safetynet'
implementation 'com.google.firebase:firebase-appcheck-debug'
I have enabled App Check in Firebase console and added the SHA-256 certificate fingerprint to it.
I have added this flag to firebase.json:
"automaticResourceManagement": true,
and finally, the initialization of the app check in index.js:
import { firebase } from '#react-native-firebase/app-check';
try {
firebase.appCheck().setTokenAutoRefreshEnabled(true);
firebase.appCheck().activate('ignored', true);
const appchecktoken = firebase.appCheck().getToken(true);
console.log("app check success, appchecktoken: " + JSON.stringify(appchecktoken));
} catch (e) {
console.log("Failed to initialize appCheck:", e);
}
When I print the appchecktoken it seems empty:
{"_U":0,"_V":0,"_W":null,"_X":null}
What am I missing here? Please remember that I am using the react-native-firebase package and not the native packages.
I feel like I have tried every possible combination of ways to report a crash on the firebase crashlytics console for the android side of my react-native application.
I have followed the rnfirebase setup instructions and triple checked that everything is where it should be: https://rnfirebase.io/crashlytics/android-setup
I have read in several forums that the app needs to be run in 'release' mode for the crash to be reported and then the app must be closed and opened once again for the report to be sent, I have done this multiple times:
firstly i've tried:
./gradlew installRelease
secondly I tried a method recommended in a github issue forum:
./gradlew assembleRelease
adb install ./app/build/outputs/apk/release/app-release.apk
both methods ran on my emulator and I was able to use the crashlytics().crash() method to cause a crash, alas nothing appears in the console.
I have also added this into a firebase.json file in the root of my project like the docs explain:
{
"react-native": {
"crashlytics_debug_enabled": true
}
}
any help is greatly appreciated as I really don't know where the issue lies.
PS. I have registered my app with the FB console and enabled crashlytics
in firebase.json
{
"react-native": {
"crashlytics_disable_auto_disabler": true,
"crashlytics_debug_enabled": true
}
}
make sure that crashanalytics sdk is installed/initialised
follow: https://rnfirebase.io/crashlytics/android-setup
Wanted to get a crash report from firebase once the app gets crashed. Is it possible to get debug mode logs separate and production crash log separate in firebase crash?...because its not really clear when we get crash from production or debug test.
Also, firebase won't reflect crash report on the console after a crash happens.
What should I do to get up to date crash report?
Is there another way to get a crash report other than firebase?
I have updated the libraries which required for the firebase crashlytics.
and Followed tutorial - https://firebase.google.com/docs/crashlytics/get-started#android
Is it possible to get debug mode logs separate and production crash log separate in firebase crash?
It's common practice or perhaps even recommended that you create a separate project for testing and production. Download and place the google-services.json in your build flavor folder
~/app/src/release/google-services.json
~/app/src/debug/google-services.json
Even if you are only having a single Firebase project for test and production, you can filter your logs by the application id if you're setting up a project id suffix for the development build flavor:
~/app/build.gradle
buildTypes {
release {
}
debug {
applicationIdSuffix '.debug'
versionNameSuffix '-dbg'
}
}
Here you can see the different flavors being available in Crashlytics
Also, firebase won't reflect crash report on the console after a crash happens.
First time that you set up crashlytics it might take some time before the data shows up in the dashboard. But if it's been over 24 hours, it's likely that it's not properly set up. Try to explicitly trigger a crash to make sure that it works fine.
Button crashButton = new Button(this);
crashButton.setText("Crash!");
crashButton.setOnClickListener(new View.OnClickListener() {
public void onClick(View view) {
Crashlytics.getInstance().crash(); // Force a crash
}
});
Is there another way to get a crash report other than firebase?
Yes you can have more than one crash reporting tool if you have the need. You can perhaps create a wrapper class for crash reporting where you abstract the call to Crashlytics and you can add or change the underlying reporting platform there.
Upgrade SDK
After making the relevant settings for the migration to the new SDK, it is important to avoid the following error:
Attempting to send crash report at time of crash.
This can be caused by forcing a crash (without a button listen in my case) before FirebaseCrashlytics send the reports, that is, the Crashlytics Reports Endpoint upload is completed.
Test implementation
Enable Crashlytics debug logging
$ adb devices
$ adb shell setprop log.tag.FirebaseCrashlytics DEBUG
$ adb logcat -s FirebaseCrashlytics
1) First step: DONT force a crash and run the app. Observing how in the Crashlyticis logcat it is initialized correctly.
...
FirebaseCrashlytics: Update app request ID: 1d62cb...
FirebaseCrashlytics: Result was 204.
Crashlytics Reports Endpoint upload complete
2) Step Two: Force a crash (with a button or directly).
MainActivity.kt
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_main)
setupCrashlytics()
...
}
private fun setupCrashlytics() {
throw RuntimeException("Test crash") //TODO: Clean
}
Note: The only thing necessary to generate a report is this code in addition to the dependencies. Additionally you can login custom keys with FirebaseCrashlytics.getInstance().
Then run the app and check the following:
FirebaseCrashlytics: Crashlytics completed exception processing. Invoking default exception handler.
FirebaseCrashlytics: Attempting to send crash report at time of crash...
At this point the exception process is logged on the Firebase server but the reports have not yet been sent to the console, that is, the upload is incomplete.
3) Finally, we clean or comment on the crash crash
private fun setupCrashlytics() {
//throw RuntimeException("Test crash")
}
Run app and let's check:
Attempting to send 1 report(s)
FirebaseCrashlytics: Settings result was: 200
FirebaseCrashlytics: Adding single file 5EDA9D7....cls to report 5EDA9D7...
FirebaseCrashlytics: Sending report to: https://reports.crashlytics.com/spi/v1/platforms/android/apps/.../reports
FirebaseCrashlytics: Crashlytics Reports Endpoint upload complete: 5EDABB42 ...
This guarantees that the report reached the console.
GL
Firebase will not differentiate between debug and production versions logs/crashes in crashlytics if you have set auto collection of logs. You can use a logging library to only send logs and crashes if the app build.gradle has debug:fasle i.e. production.
You can look at the Timber logging library which has a great example of adding crash reporting. https://github.com/JakeWharton/timber
You have to disable the auto initialization of crashlytics in manifest to have control when crashes are sent to firebase
<meta-data
android:name="firebase_crashlytics_collection_enabled"
android:value="false" />
Then in your Application class's onCreate you check if BuildConfig.DEBUG is true you will not initialize crashlaytics so your debug logs and exceptions will not go to firebase, resulting in only production crashes.
For timber when you want to put logs and crashes to firebase you can use this Tree:
/**
* {#link Timber.Tree} using {#link Crashlytics} as crash reporting
*/
private static class CrashReportingTree extends Timber.Tree {
CrashReportingTree(Context context) {
CrashlyticsCore core = new CrashlyticsCore.Builder()
.disabled(BuildConfig.DEBUG)
.build();
Fabric.with(context, new Crashlytics.Builder().core(core).build());
}
#Override
protected void log(int priority, String tag, #NonNull String message, Throwable t) {
// don't report log to Crashlytics if priority is Verbose or Debug
if (priority == Log.VERBOSE || priority == Log.DEBUG) {
return;
}
Crashlytics.log(priority, tag, message);
if (t != null) {
if (priority == Log.ERROR) {
Crashlytics.logException(t);
}
}
}
}
For debug mode you should not send crashes to firebase as you can check the debug logs locally.
Please remove fabric.properties and remove all fabric related lines and files
I solve this issue thanks to AllwinJohnson solution in:
https://github.com/firebase/firebase-android-sdk/issues/1944
By Adding: FirebaseCrashlytics.getInstance()
in my onCreate in my Application class
The issue for me was the emulator itself. Fixing the date and time on the emulator did it for me as it was resulting in a CertificateNotYetValidException.
This will help if you moved from fabric SDK to Firebase Crashlytics.
Add the below line in your OnCreate() run the app and check your firebase crashlytics dashboard.
FirebaseCrashlytics.getInstance().sendUnsentReports();
In my case, I made the silly mistake of doing:
FirebaseCrashlytics.getInstance().setUserId(uid);
where uid was still null.
Problem
Issue while getting mapbox bounds coordinates using this.map refereance #mapbox/react-native-mapbox-gl npm module. I used getVisibleBounds() method but it will not resolve promise any how.
try {
let bounds = await this.map.getVisibleBounds();
console.log("Bounds : ", bounds);
} catch (err) {
console.log("Error : ", err);
}
I used below dependecy for React-Native App with Android.
"#mapbox/react-native-mapbox-gl": "6.1.2-beta2"
"react": "16.3.1"
"react-native": "0.55.4"
It will neither print Bounds nor Error
Any please help me solve out this problem
There is issue raise on gitgub mapbox repo as well but they also didn't reply on this issue. You can check on below link for more details.
Reported same issue on Github too
This may not be the issue, but, are you getting this in your logcat console in your Android Studio?
09-19 11:15:01.070 5390-5390/com.endurance W/unknown:ReactNative: Calling JS function after bridge has been destroyed: RCTEventEmitter.receiveEvent([913,"rct.mapbox.map.androidcallback",{"payload":{"visibleBounds":[[-121.96388609239466,37.47651057926733],[-122.2038196399402,37.36744637395246]]},"type":"1537352098529"}])
Calling JS function after bridge has been destroyed: RCTEventEmitter.receiveEvent([913,"rct.mapbox.map.change",{"payload":{},"type":"didfinishrenderingmapfully"}])
Calling JS function after bridge has been destroyed: RCTEventEmitter.receiveEvent([913,"rct.mapbox.map.change",{"payload":{},"type":"didfinishloadingmap"}])
It seems that event is emitted after the bridge has been destroyed. If you are debugging, try to close your debugger console (React Native Debugger), disable Live Reload/Hot Reload > Rebuild.
It seems that some events are killed in debug process, see mapbox issue here:
https://github.com/mapbox/react-native-mapbox-gl/issues/1189
I face issue with get token from firebase (push notification)
Default FirebaseApp is not initialized in this process com.ready_apps.Nebka.Business. Make sure to call FirebaseApp.initializeApp(Context) first.
even I called FirebaseApp.InitializeApp(this); in many places
MyApplication (that extend Application) , in onCreate of Activity where I call FirebaseInstanceId.Instance?.Token;
Edit: This bug has been fixed in Xamarin.Firebase version 57.1104.0-beta1.
This error seems to be present in the newer versions of Firebase for Xamarin. I am also experiencing this error as of today, using the latest stable version 42.1021.1. (The error is also present in the latest beta build).
I found that a bug report has been filed for the issue here.
As mentioned in the bug report, deleting both the /obj and /bin folders in your Android project, and/or cleaning the project in Visual Studio should fix the problem temporarily until you update any resource that would change the Resource.Designer.cs file.
Downgrading to an older version of Firebase and Google Play Services is also possible before a permanent solution is available. I did not experience this error on Firebase and Google Play Services version 32.961.0, for example.
Just Clean the solution once and run the app again.
This bug is already reported to Xamarin.
https://bugzilla.xamarin.com/show_bug.cgi?id=56108
This solution is provided in their comment thread, it might get fixed in the newer release of xamarin NuGet package.
I didnt fix it but I find walkaround this issue in debug mode only
I called this method onCreate() in activit I need to request the token
FirebaseInstanceId.Instance?.Token
here is the method
private void ConfigureFireBase()
{
#if DEBUG
try
{
Task.Run(() =>
{
var instanceId = FirebaseInstanceId.Instance;
instanceId?.DeleteInstanceId();
//Log.Debug("TAG", "{0} {1}", instanceId?.Token?.ToString(), instanceId.GetToken(GetString(Resource.String.gcm_defaultSenderId), Firebase.Messaging.FirebaseMessaging.InstanceIdScope));
});
// For debug mode only - will accept the HTTPS certificate of Test/Dev server, as the HTTPS certificate is invalid /not trusted
ServicePointManager.ServerCertificateValidationCallback += (o, certificate, chain, errors) => true;
}catch (Exception e)
{
Log.Debug("TAG", e.Message);
}
#endif
}