I have integrated firebase Crashlytics on a react native application. I want to disable crash logs while working on development mode. How can I disable crash logs in debug mode for both Android and Ios Application. To create crash logs I have followed react native firebase documentation check this official link :: https://rnfirebase.io/docs/v5.x.x/crashlytics/android
I am using react-native-firebase version 5.2.2
I want to disable logs on debug mode without changing the version. I want to add code to disable the crash log for both Android and Ios. Please suggest how this should be done.
The documentation explains how to disable it
iOS
Turn off automatic collection with a new key to your Info.plist file:
Key: firebase_crashlytics_collection_enabled
Value: false
<key>firebase_crashlytics_collection_enabled</key>
<false/>
Android
Turn off automatic collection with a meta-data tag in your AndroidManifest.xml file:
<meta-data
android:name="firebase_crashlytics_collection_enabled"
android:value="false" />
Enable collection at runtime
You can can initialise crashlytics in your javascript code using
firebase.crashlytics().enableCrashlyticsCollection();
You can then use
if (__DEV__) {
} else {
}
to run any specific code in development or in production.
I only need to set one line in firebase.json file,
{
"react-native": {
"crashlytics_debug_enabled": false
}
}
faced the same in one of my project : "react-native": "0.66.1"
Edit AndroidManifest.xml
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.reversedomain">
<application
...
...
// add this line
<meta-data
android:name="firebase_crashlytics_collection_enabled"
android:value="false" />
</application>
install '#react-native-firebase/crashlytics'
add .env at the root of your project & set production = false
in app.js
import React from 'react'
import { production } from '#env';
import crashlytics from '#react-native-firebase/crashlytics';
useEffect(()=>{
if (production == true) {
// Enable on runtime
crashlytics().setCrashlyticsCollectionEnabled(true);
}
},[])
docs
Related
I am getting crash on app launch in android with below error.
Native Client is not available, can't start on native.
Sentry.init({
enableNative: true,
enableNativeCrashHandling: true,
dsn:
'https://xyx.com/sentry/12',
})
When I set enableNative: false, then the crash stops coming but the android related crashes are not logged in sentry.
I have added sentry in build.gradle as well as per the sentry integration doc.
Any solution for this?
I had this problem as well, using the test of Sentry.nativeCrash() - the application would crash, but not be reported.
To fix, set autoInitializeNativeSdk to false and initialize in the AndroidManifest.
Sentry.init({
autoInitializeNativeSdk: false,
dsn:
'https://xyx.com/sentry/12',
})
Initialize the AndroidSDK in your AndroidManifest.xml
<application>
<meta-data android:name="io.sentry.auto-init" tools:replace="android:value" android:value="true" />
<meta-data android:name="io.sentry.dsn" android:value="https://examplePublicKey#o0.ingest.sentry.io/0" />
</application>
Make sure you add xmlns:tools="http://schemas.android.com/tools" to your manifest.
Follow the below link for documentation.
Native Initialize
I have an app that utilises Fabric's Crashlytics via Firebase.
The following is the first thing executed in my Applications onCreate
CrashlyticsCore crashlyticsCore = new CrashlyticsCore.Builder()
.disabled(BuildConfig.DEBUG)
.build();
Fabric.with(this, new Crashlytics.Builder().core(crashlyticsCore).build());
Nonetheless, the crashes are submitted in DEBUG == true mode.
I use the following versions
in my build.gradle
classpath "io.fabric.tools:gradle:1.25.1"
in my app/build.gradle
implementation "com.crashlytics.sdk.android:crashlytics:2.9.1"
Unfortunately the crashes still get reported. Any ideas, what I am doing wrong?
Correct answers have been posted by Bob Snyder and niqueco already however it seems kinda tedious to change the meta-data value every time you are building an actual release APK thus here's a solution that uses so called manifestPlaceholder and changes the value automatically to trueor false depending on the buildType.
Add the following to your apps build.gradle
android {
// ...
buildTypes {
debug {
manifestPlaceholders = [enableCrashReporting:"false"]
}
release {
manifestPlaceholders = [enableCrashReporting:"true"]
}
}
}
And this to your AndroidManifest.xml
<manifest ... >
<application ...>
// ...
<meta-data android:name="firebase_crashlytics_collection_enabled" android:value="${enableCrashReporting}" />
</application>
</manifest>
You can verify the current value by clicking on the Merged Manifest tab once you have opened the AndroidManifest.xml. You should see something like this:
The Firebase Crashlytics documentation explains that once reporting is enabled in an app session, it cannot be disabled.
By default, Crashlytics reporting is enabled in a ContentProvider named CrashlyticsInitProvider that executes before your Application instance is created. CrashlyticsInitProvider enables or disables reporting based on the meta-data value firebase_crashlytics_collection_enabled, which by default is true.
If you want reporting disabled, it's critical that the manifest meta-data be present and set to false:
<meta-data
android:name="firebase_crashlytics_collection_enabled"
android:value="false" />
Look in the logcat during app initialization for the message:
CrashlyticsInitProvider: CrashlyticsInitProvider initialization successful
If the message is present, firebase_crashlytics_collection_enabled is true. If the message is not present, you have successfully set the meta-data to disable crash reporting.
If the meta-data is missing or set to true, you cannot disable reporting in your code using a call to Fabric.with(...).
In a comment to another answer, you indicate that you tried disabling reporting using the meta-data and were not successful. Check for a typo and ensure the declaration is correctly placed in the <application> element. In my tests, I am able to disabling reporting using the meta-data and then enable at run time.
I've finally found the issue. Crashlytics is initialized from a content provider, so by the time you try to disable from Application's onCreate() it's too late. Going through the decompiled code I've seen that you can disable that initialization by adding metadata to the <application> element in the manifest.
So, what I do is this... I've added this to app/src/debug/AndroidManifest.xml
<?xml version="1.0" encoding="utf-8"?><!--suppress ALL -->
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="<your app package>">
<application>
<meta-data android:name="firebase_crashlytics_collection_enabled" android:value="false" />
</application>
</manifest>
I've also disabled Crashlytics in the app module gradle build file by adding:
debug {
ext.enableCrashlytics = false
}
To my surprise I didn't need to do the Fabric.with(...) thing. The above was enough.
It's working fine: no reports.
I think it is possible to do it from code as well if you switched to firebase crashlytics and removed fabric crashlytics :
link to firebase doc
So in the onCreate of your application class :
FirebaseCrashlytics.getInstance().setCrashlyticsCollectionEnabled(!BuildConfig.DEBUG);
Got this information from android documentation
Customize your Firebase Crash Reports
Enable opt-in reporting:
By default, Firebase Crashlytics automatically collects crash reports for all your app's users. To give users more control over the data they send, you can enable opt-in reporting instead.
To do that, you have to disable automatic collection and initialize Crashlytics only for opt-in users.
Turn off automatic collection with a meta-data tag in your AndroidManifest.xml file:
<meta-data
android:name="firebase_crashlytics_collection_enabled"
android:value="false" />
Enable collection for selected users by initializing Crashlytics from one of your app's activities:
Fabric.with(this, new Crashlytics());
You need to disable Crashlytics of app’s build.gradle. Disable Crashlytics for Debug Builds
android {
buildTypes {
debug {
// Disable fabric build ID generation for debug builds
ext.enableCrashlytics = false
...
If you would like to completely disable Firebase Crash reporting AND also not have to add the
com.crashlytics.sdk.android:crashlytics:2.9.1
dependency, then follow #reVerse's answer but also add this to your AndroidManifest.xml:
<application ...>
// ...
<meta-data
android:name="firebase_crashlytics_collection_enabled"
android:value="${enableCrashReporting}" />
<meta-data
android:name="firebase_analytics_collection_deactivated"
android:value="true"/>
</application>
I am trying to integrate google_maps_flutter into an existing project.
The maps component works only when running directly the "my_flutter" project on the device (the same code).
When I try to run the flutter module from an existing app, the maps component is empty and no logs are available (or usable).
(Flutter doctor does not output any errors).
I've followed the steps for both the my_flutter/.iOS and my_flutter/.android projects and I also followed them for the projects that integrate my_flutter.
Source:
Android
Specify your API key in the application manifest
android/app/src/main/AndroidManifest.xml:
<manifest ...
<application ...
<meta-data android:name="com.google.android.geo.API_KEY"
android:value="YOUR KEY HERE"/>
iOS
Specify your API key in the application delegate ios/Runner/AppDelegate.m:
include "AppDelegate.h"
include "GeneratedPluginRegistrant.h"
import "GoogleMaps/GoogleMaps.h"
#implementation AppDelegate
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
[GMSServices provideAPIKey:#"YOUR KEY HERE"];
[GeneratedPluginRegistrant registerWithRegistry:self];
return [super application:application didFinishLaunchingWithOptions:launchOptions];
}
#End
Opt-in to the embedded views preview by adding a boolean property to
the app's Info.plist file with the key
io.flutter.embedded_views_preview and the value YES.
I suspect that I what I am trying is not possible yet with the current version on the library and it may come as a new feature when the library is not in "developer preview".
Found that I had to:
GeneratedPluginRegistrant.register(with: flutterViewController.pluginRegistry());
Did you set a latitude and longitude in the Google Maps param?
If you're setting your API key and doing what it said, it should work fine
I am using Firebase in my android project. Wanted to know how to disable it in development mode. All crashes and usage/events are being logged and messing up with actual analytics.
Any better way to disable this in development mode?
Checkout https://firebase.google.com/docs/analytics/configure-data-collection?platform=android
<meta-data android:name="firebase_analytics_collection_deactivated" android:value="true" />
To do this automatically add the following line to manifest:
<meta-data
android:name="firebase_analytics_collection_deactivated"
android:value="#bool/FIREBASE_ANALYTICS_DEACTIVATED"/>
Set different value of boolean for debug and release in your app/build.gradle
buildTypes {
debug {
resValue("bool", "FIREBASE_ANALYTICS_DEACTIVATED", "true")
}
release {
resValue("bool", "FIREBASE_ANALYTICS_DEACTIVATED", "false")
}
}
Add this line to your manifest file while development.
<meta-data android:name="firebase_analytics_collection_deactivated" android:value="true" />
For more details check https://firebase.google.com/support/guides/disable-analytics
It would be better to separate your dev and prod environments instead of disabling things completely. You have options on how to implement this, so you can choose what suits your team the best. This blog post details your options: https://firebase.googleblog.com/2016/08/organizing-your-firebase-enabled-android-app-builds.html
public class MyApp extends Application {
public static boolean isDebuggable;
public void onCreate() {
super.onCreate();
isDebuggable = (0 != (getApplicationInfo().flags & ApplicationInfo.FLAG_DEBUGGABLE));
FirebaseCrash.setCrashCollectionEnabled(!isDebuggable);
}
}
Since Google Play Services / Firebase 11+, we can programmatically disable the Firebase Crashlytics at runtime.
FirebaseCrashlytics.getInstance().setCrashlyticsCollectionEnabled(false);
To disable Firebase Crashlytics in Debug builds:
FirebaseCrashlytics.getInstance().setCrashlyticsCollectionEnabled(!BuildConfig.DEBUG);
or for better readability:
if(BuildConfig.DEBUG) {
FirebaseCrashlytics.getInstance().setCrashlyticsCollectionEnabled(false);
}
I am implementing facebook account kit in android app. I've completed initial setup and when I run the app it displays error
We're sorry, something went wrong.
https://developers.facebook.com/docs/accountkit/android
I searched a lot but did not find anything helpful.
If anyone has something to share please share here.
You need to go through link
https://developers.facebook.com/apps/ ----Your-App-ID--- /account-kit/
you can see Enable client access token flow.
make it yes.
#JayVDiyk You can get more information for an error by setting the debug flag of the init method to true, for more information about the reference:
https://developers.facebook.com/docs/accountkit/webjs/reference
The way you could set init method to true:
AccountKit.init({appId: 1, state: state, version: 'v1.0', debug: true})
Else you could try the solution by adding the http://localhost:3000' like this:
Make sure you set up the Account kit properly. The error shows with incorrect setup in my case.
steps are:
Generate Key Hash
Create a Facebook App.
Add Account Kit to your Facebook App
Android Integration
a. Gradle Dependencies
Add dependency in gradle for Account Kit
repositories {
jcenter()
}
dependencies {
compile 'com.facebook.android:account-kit-sdk:4.+'
}
b. Android Manifest
Add the following to the AndroidManifest.xml
<meta-data android:name="com.facebook.accountkit.ApplicationName" android:value="#string/app_name" />
<meta-data android:name="com.facebook.sdk.ApplicationId" android:value="#string/facebook_app_id" />
<meta-data android:name="com.facebook.accountkit.ClientToken" android:value="#string/account_kit_client_token" />
<activity
android:name="com.facebook.accountkit.ui.AccountKitActivity"
android:theme="#style/AppLoginTheme"
tools:replace="android:theme"/>
Please Go through this links:
1) Link 1
2) Link 2