Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Android - Crashlytics logs not showing in crashes, on the Firebase Console #3648

Closed
6 tasks
GiladR1979 opened this issue May 14, 2020 · 11 comments
Closed
6 tasks
Labels
plugin: crashlytics Firebase Crashlytics Type: Stale Issue has become stale - automatically added by Stale bot

Comments

@GiladR1979
Copy link

I recently changed Crashlytics from Fabric to React Native Crashlytics.
I have set a new error handler on JS with Crashlytics log commands.
I am getting crashes on both iOS and Android, but no logs in Android, also, not seeing other analytics events in the crash log, although I am still getting analytics from Android.

Project Files

Javascript

Click To Expand

package.json:

"dependencies": {
  ...
    "@react-native-firebase/app": "6.4.1-alpha.0",
    "@react-native-firebase/crashlytics": "6.4.1-alpha.0",
    "@react-native-firebase/messaging": "6.4.1-alpha.0",
...
}

firebase.json for react-native-firebase v6:

{
  "react-native": {
    "messaging_android_notification_channel_id": "high-priority"
  }
}

Android

Click To Expand

Have you converted to AndroidX?

  • my application is an AndroidX application?
  • I am using android/gradle.settings jetifier=true for Android compatibility?
  • [x ] I am using the NPM package jetifier for react-native compatibility?

android/build.gradle:

// Top-level build file where you can add configuration options common to all sub-projects/modules.

buildscript {
    ext {
        ...
    }
    repositories {
        maven {
            url 'https://maven.google.com/'
            name 'Google'
        }
        jcenter()
        google()
        maven { url 'https://maven.fabric.io/public' }
    }
    dependencies {
        classpath('com.android.tools.build:gradle:3.5.3')
        classpath "org.jfrog.buildinfo:build-info-extractor-gradle:4.0.1"
        classpath 'io.fabric.tools:gradle:1.26.1'
        classpath 'com.google.gms:google-services:4.3.3'

        // NOTE: Do not place your application dependencies here; they belong
        // in the individual module build.gradle files
    }
}

allprojects {
    repositories {
        mavenLocal()
        maven {
            // All of React Native (JS, Obj-C sources, Android binaries) is installed from npm
            url("$rootDir/../node_modules/react-native/android")
        }
        maven {
            // Android JSC is installed from npm
            url("$rootDir/../node_modules/jsc-android/dist")
        }
        
        maven {
            url 'https://maven.google.com/'
            name 'Google'
        }
        maven {
            url "https://jitpack.io"
        }
        google()
        jcenter()
    }
}

android/app/build.gradle:

...
repositories {
    maven { url 'https://maven.fabric.io/public' }
}

dependencies {
    implementation project(':@react-native-firebase_crashlytics')
    implementation project(':@react-native-community_datetimepicker')
    implementation project(':react-native-fast-image')
    implementation project(':react-native-svg')
    implementation project(':react-native-screens')
    implementation project(':react-native-reanimated')
    implementation project(':react-native-gesture-handler')
    implementation 'androidx.appcompat:appcompat:1.1.0'
    implementation 'androidx.swiperefreshlayout:swiperefreshlayout:1.1.0-alpha03'
    implementation project(':@react-native-community_masked-view')
    implementation project(':react-native-linear-gradient')
    implementation project(':react-native-device-info')

    implementation 'com.android.support:design:29.0.0'

    implementation fileTree(include: ['*.jar'], dir: 'libs')
    implementation 'com.android.support:appcompat-v7:29.0.0'
    implementation 'com.facebook.react:react-native:0.61.2'

    api "androidx.work:work-runtime:2.3.0"

    if (enableHermes) {
        def hermesPath = "../../node_modules/hermes-engine/android/"
        debugImplementation files(hermesPath + "hermes-debug.aar")
        releaseImplementation files(hermesPath + "hermes-release.aar")
    } else {
        implementation jscFlavor
    }

    implementation "com.toluna:jobqueue:$JOBQUEUE_SDK_VERSION"
    implementation "com.toluna:deviceusagesdk:$SDK1_VERSION"
    implementation "com.toluna:digitaltrackingsdk:$SDK2_VERSION"

    implementation 'com.google.firebase:firebase-core:17.2.2'

    implementation 'com.squareup.retrofit2:retrofit:2.4.0'
    implementation 'com.squareup.retrofit2:converter-gson:2.4.0'

    implementation "com.google.dagger:dagger-android-support:$DAGGER_VERSION"
    implementation "com.google.dagger:dagger:$DAGGER_VERSION"
    implementation "com.google.dagger:dagger-android:$DAGGER_VERSION"
    annotationProcessor "com.google.dagger:dagger-android-processor:$DAGGER_VERSION"
    annotationProcessor "com.google.dagger:dagger-compiler:$DAGGER_VERSION"


    compileOnly 'javax.annotation:jsr250-api:1.0'
    implementation 'com.google.code.gson:gson:2.8.5'
    implementation 'com.github.Abhi347:LumberJack:0.0.3'

    implementation('com.crashlytics.sdk.android:crashlytics:2.9.9@aar') {
        transitive = true
    }

    //Required: Google Play Services Ads Identifier (If publishing to Google Play)
    implementation 'com.google.android.gms:play-services-ads-identifier:17.0.0'
    //Required: Install Referrer (If publishing to Google Play)
    implementation 'com.android.installreferrer:installreferrer:1.1.1'

    implementation 'com.google.firebase:firebase-messaging:20.1.0'
    implementation project(':@react-native-community_async-storage')
    implementation project(':react-native-community-netinfo')
    implementation project(':react-native-webview')
    implementation project(':react-native-video')
    implementation project(':lottie-react-native')
    implementation project(':react-native-orientation-locker')
}
...

android/settings.gradle:

rootProject.name = 'ConsumerInsightProgram'
include ':@react-native-firebase_crashlytics'
project(':@react-native-firebase_crashlytics').projectDir = new File(rootProject.projectDir, '../node_modules/@react-native-firebase/crashlytics/android')
include ':react-native-fast-image'
project(':react-native-fast-image').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-fast-image/android')
apply from: file("../node_modules/@react-native-community/cli-platform-android/native_modules.gradle")
applyNativeModulesSettingsGradle(settings)
include ':app'


include ':@react-native-community_masked-view'
project(':@react-native-community_masked-view').projectDir = new File(rootProject.projectDir, '../node_modules/@react-native-community/masked-view/android')

include ':react-native-linear-gradient'
project(':react-native-linear-gradient').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-linear-gradient/android')

include ':@react-native-community_async-storage'
project(':@react-native-community_async-storage').projectDir = new File(rootProject.projectDir, '../node_modules/@react-native-community/async-storage/android')

include ':react-native-community-netinfo'
project(':react-native-community-netinfo').projectDir = new File(rootProject.projectDir, '../node_modules/@react-native-community/netinfo/android')

include ':react-native-webview'
project(':react-native-webview').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-webview/android')

include ':react-native-device-info'
project(':react-native-device-info').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-device-info/android')

include ':react-native-video'
project(':react-native-video').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-video/android-exoplayer')

include ':react-native-screens'
project(':react-native-screens').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-screens/android')

include ':react-native-reanimated'
project(':react-native-reanimated').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-reanimated/android')

include ':react-native-gesture-handler'
project(':react-native-gesture-handler').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-gesture-handler/android')

include ':react-native-svg'
project(':react-native-svg').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-svg/android')

include ':@react-native-community_datetimepicker'
project(':@react-native-community_datetimepicker').projectDir = new File(rootProject.projectDir, '../node_modules/@react-native-community/datetimepicker/android')

include ':lottie-react-native'
project(':lottie-react-native').projectDir = new File(rootProject.projectDir, '../node_modules/lottie-react-native/src/android')

include ':react-native-orientation-locker'
project(':react-native-orientation-locker').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-orientation-locker/android')

include ':@react-native-firebase_app'
project(':@react-native-firebase_app').projectDir = new File(rootProject.projectDir, './../node_modules/@react-native-firebase/app/android')

include ':@react-native-firebase_messaging'
project(':@react-native-firebase_messaging').projectDir = new File(rootProject.projectDir, './../node_modules/@react-native-firebase/messaging/android')

include ':react-native-push-notification'
project(':react-native-push-notification').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-push-notification/android')

MainApplication.java:

...
package com.***.***;

import android.app.Activity;
import android.app.Application;
import android.content.Context;
import android.content.pm.ActivityInfo;
import android.os.Build;
import android.os.Bundle;

import com.crashlytics.android.Crashlytics;
import com.facebook.react.ReactApplication;
import io.invertase.firebase.crashlytics.ReactNativeFirebaseCrashlyticsPackage;
import com.reactcommunity.rndatetimepicker.RNDateTimePickerPackage;
import com.dieam.reactnativepushnotification.ReactNativePushNotificationPackage;
import com.dylanvann.fastimage.FastImageViewPackage;
import com.horcrux.svg.SvgPackage;
import com.swmansion.rnscreens.RNScreensPackage;
import com.swmansion.reanimated.ReanimatedPackage;
import com.swmansion.gesturehandler.react.RNGestureHandlerPackage;
import org.reactnative.maskedview.RNCMaskedViewPackage;
import com.BV.LinearGradient.LinearGradientPackage;
import com.facebook.react.ReactNativeHost;
import com.facebook.react.ReactPackage;
import com.facebook.react.shell.MainReactPackage;
import com.facebook.soloader.SoLoader;
import com.toluna.digitaltrackingsdk.CertificateActivity;
import com.toluna.digitaltrackingsdk.TestVPNActivity;
import com.toluna.digitaltrackingsdk.VPNActivity;
import com.reactnativecommunity.asyncstorage.AsyncStoragePackage;
import com.reactnativecommunity.netinfo.NetInfoPackage;
import com.reactnativecommunity.webview.RNCWebViewPackage;
import org.wonday.orientation.OrientationPackage;
import com.airbnb.android.react.lottie.LottiePackage;

import com.learnium.RNDeviceInfo.RNDeviceInfo;
import android.content.Context;
import android.webkit.WebView;

import com.facebook.react.PackageList;
import java.lang.reflect.InvocationTargetException;

import java.util.Arrays;
import java.util.List;

import io.fabric.sdk.android.Fabric;

import com.brentvatne.react.ReactVideoPackage;

import com.airbnb.android.react.lottie.LottiePackage;
import com.lugg.ReactNativeConfig.ReactNativeConfigPackage;
import io.invertase.firebase.app.ReactNativeFirebaseAppPackage;
import io.invertase.firebase.messaging.ReactNativeFirebaseMessagingPackage;

public class MainApplication extends Application implements ReactApplication {

	private static final Class<?> clazz = MainApplication.class;

	private static MainApplication instance;

	public MainApplication() {
		instance = this;
	}


	private final ReactNativeHost mReactNativeHost = new ReactNativeHost(this) {
		@Override
		public boolean getUseDeveloperSupport() {
			return BuildConfig.DEBUG;
		}

		@Override
		protected List<ReactPackage> getPackages() {
			return Arrays.asList(
				new RNDeviceInfo(),
				new MainReactPackage(),
            new ReactNativeFirebaseCrashlyticsPackage(),
            new RNDateTimePickerPackage(),
                new FastImageViewPackage(),
            	new SvgPackage(),
				new RNScreensPackage(),
				new ReanimatedPackage(),
				new RNGestureHandlerPackage(),
				new RNCMaskedViewPackage(),
				new LinearGradientPackage(),
				new AsyncStoragePackage(),
				new NetInfoPackage(),
				new RNCWebViewPackage(),
				new ReactVideoPackage(),
                new LottiePackage(),
				new OrientationPackage(),
				new ReactNativeConfigPackage(),
                new ReactNativeFirebaseAppPackage(),
                new ReactNativeFirebaseMessagingPackage(),
                new ReactNativePushNotificationPackage()
			);
		}

		@Override
		protected String getJSMainModuleName() {
			return "index";
		}
	};

	@Override
	public ReactNativeHost getReactNativeHost() {
		return mReactNativeHost;
	}

	@Override
	public void onCreate() {
		super.onCreate();
		final String funcName = "onCreate";
		SoLoader.init(this, /* native exopackage */ false);
		initializeFlipper(this); // Remove this line if you don't want Flipper enabled

		AnalyticsMgr.init(this);

		limitToPortrait();
	}

	private void limitToPortrait() {
		// register to be informed of activities starting up
		registerActivityLifecycleCallbacks(new ActivityLifecycleCallbacks() {

			@Override
			public void onActivityCreated(Activity activity, Bundle savedInstanceState) {
				Class<?> activityClass = activity.getClass();
				if (activityClass != VPNActivity.class &&
						activityClass != TestVPNActivity.class &&
						activityClass != CertificateActivity.class) {
					activity.setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);
				}
			}

			@Override
			public void onActivityStarted(Activity activity) {
			}
			@Override
			public void onActivityResumed(Activity activity) {
			}
			@Override
			public void onActivityPaused(Activity activity) {
			}
			@Override
			public void onActivityStopped(Activity activity) {
			}
			@Override
			public void onActivitySaveInstanceState(Activity activity, Bundle outState) {
			}
			@Override
			public void onActivityDestroyed(Activity activity) {
			}
		});
	}

	/**
	 * Loads Flipper in React Native templates.
	 *
	 * @param context
	 */
	private static void initializeFlipper(Context context) {
		if (BuildConfig.DEBUG) {
			try {
        /*
         We use reflection here to pick up the class that initializes Flipper,
        since Flipper library is not available in release mode
        */
				Class<?> aClass = Class.forName("com.facebook.flipper.ReactNativeFlipper");
				aClass.getMethod("initializeFlipper", Context.class).invoke(null, context);
			} catch (ClassNotFoundException e) {
				e.printStackTrace();
			} catch (NoSuchMethodException e) {
				e.printStackTrace();
			} catch (IllegalAccessException e) {
				e.printStackTrace();
			} catch (InvocationTargetException e) {
				e.printStackTrace();
			}
		}
	}

	public void onLowMemory() {
		final String funcName = "onLowMemory";
		super.onLowMemory();
		TlnLog.e(clazz, funcName, "LOW MEMORY");
	}

	public void onTrimMemory(int level) {
		final String funcName = "onTrimMemory";
		super.onTrimMemory(level);
	}

	public static MainApplication getInstance() {
		return instance;
	}

	public static Context getContext() {
		Context result = instance.getApplicationContext();
		return result;
	}

}

...

AndroidManifest.xml:

<manifest
    xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    package="com.***.***"
    android:sharedUserId="com.***.***"
    >

    <uses-permission android:name="android.permission.INTERNET" />
    <uses-permission android:name="android.permission.FOREGROUND_SERVICE" />
    <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
    <uses-permission android:name="android.permission.PACKAGE_USAGE_STATS" tools:ignore="ProtectedPermissions" />

    <application
        android:name="com.***.***.MainApplication"
        android:allowBackup="false"
        android:label="@string/app_name"
        android:icon="@mipmap/ic_launcher"
        android:theme="@style/AppTheme"
        android:networkSecurityConfig="@xml/network_security_config"
        tools:replace="android:allowBackup"
        tools:ignore="GoogleAppIndexingWarning"
        tools:targetApi="n"
        >

        <activity
            android:name="com.***.***.MainActivity"
            android:label="@string/app_name"
            android:configChanges="keyboard|keyboardHidden|orientation|screenSize"
            android:windowSoftInputMode="adjustResize">
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />
                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>

        </activity>

        <activity android:name="com.facebook.react.devsupport.DevSettingsActivity" />

            <intent-filter>
                <action android:name="android.intent.action.BOOT_COMPLETED" />
                <action android:name="android.intent.action.QUICKBOOT_POWERON"/>
            </intent-filter>
        </receiver>


        <meta-data
                android:name="io.fabric.ApiKey"
                android:value="${FABRIC_API_KEY}"
        />

        <meta-data
                android:name="com.google.firebase.messaging.default_notification_icon"
                android:resource="@mipmap/ic_notification"/>
    </application>

</manifest>


Environment

Click To Expand

react-native info output:

info Fetching system and libraries information...
System:
    OS: macOS 10.15.4
    CPU: (8) x64 Intel(R) Core(TM) i7-7820HQ CPU @ 2.90GHz
    Memory: 1.61 GB / 16.00 GB
    Shell: 5.7.1 - /bin/zsh
  Binaries:
    Node: 12.12.0 - /usr/local/bin/node
    Yarn: 1.21.1 - ~/.yarn/bin/yarn
    npm: 6.11.3 - /usr/local/bin/npm
    Watchman: 4.9.0 - /usr/local/bin/watchman
  SDKs:
    iOS SDK:
      Platforms: iOS 13.4, DriverKit 19.0, macOS 10.15, tvOS 13.4, watchOS 6.2
    Android SDK:
      API Levels: 23, 26, 27, 28, 29
      Build Tools: 28.0.3, 29.0.0
      System Images: android-27 | Google Play Intel x86 Atom, android-28 | Google APIs Intel x86 Atom, android-29 | Google APIs Intel x86 Atom, android-29 | Google Play Intel x86 Atom
  IDEs:
    Android Studio: 3.5 AI-191.8026.42.35.6010548
    Xcode: 11.4.1/11E503a - /usr/bin/xcodebuild
  npmPackages:
    react-native: 0.61.2 => 0.61.2
  npmGlobalPackages:
    react-native-cli: 2.0.1
  • Platform that you're experiencing the issue on:
    • iOS
    • [x ] Android
    • iOS but have not tested behavior on Android
    • Android but have not tested behavior on iOS
    • Both
  • react-native-firebase version you're using that has this issue:
    • 6.4.1-alpha.0
  • Firebase module(s) you're using that has the issue:
    • Crashlytics
  • Are you using TypeScript?
    • N


@Stackflood
Copy link

hi @GiladR1979 , I am trying to use this library for crashlytics. Can you please guide me through it's installation on iOS. This step is breaking the App for me : https://rnfirebase.io/crashlytics/ios-setup

@kckunal2612
Copy link

hi @GiladR1979 , I am trying to use this library for crashlytics. Can you please guide me through it's installation on iOS. This step is breaking the App for me : https://rnfirebase.io/crashlytics/ios-setup

I'm having the same issue - unable to see any logs on console for iOS, but its working fine for Android. And its been 5 days since I haven't seen any logs (so that 48 hour window is long gone).

@aliceathens
Copy link

Same not seeing anything in Firebase either for iOS came from Fabric..

@russellwheatley
Copy link
Member

We're currently in the process of upgrading to the latest version of firebase Crashlytics as per this PR #3580 which will remove Fabric as a dependency. Not sure if this will solve your problem, but it will at least be a better starting point than trying to debug the current version only for the Crashlytics upgrade making the bug fix obselete.

@russellwheatley russellwheatley added the plugin: crashlytics Firebase Crashlytics label May 21, 2020
@ghasemikasra39
Copy link

Dear @russellwheatley
Crashlytics reports the issues with a big delay on the Firebase console. Sometimes takes a couple of hours to see the corresponding issue on the console. Are you also addressing this issue in the new upgrade?

@mikehardy
Copy link
Collaborator

@ghasemikasra39 delays in crashlytics reporting are the underlying firebase SDKs and the crashlytics system, there is nothing react-native-firebase can do. It is worth noting that the crash report will not even leave your device normally until you restart the app (so crashlytics runs again, notices there is a crash and sends the report). My lag is normally just a few minutes, personally - but again it is variable and not in react-native-firebase control. No change made here will affect the lag.

@Luckygirlllll
Copy link

Any updates about this issue? I'm not getting crash reports in IOS.

@stale
Copy link

stale bot commented Jul 13, 2020

Hello 👋, to help manage issues we automatically close stale issues.
This issue has been automatically marked as stale because it has not had activity for quite some time. Has this issue been fixed, or does it still require the community's attention?

This issue will be closed in 15 days if no further activity occurs.
Thank you for your contributions.

@stale stale bot added the Type: Stale Issue has become stale - automatically added by Stale bot label Jul 13, 2020
@stale
Copy link

stale bot commented Jul 29, 2020

Closing this issue after a prolonged period of inactivity. If this is still present in the latest release, please feel free to create a new issue with up-to-date information.

@stale stale bot closed this as completed Jul 29, 2020
@SurajMDurgad
Copy link

I'm facing this issue, crashes get registered but the log doesn't show up only for Android, on iOS it works great.

@mikehardy
Copy link
Collaborator

This is from May, if you have problems please open a new issue, ensuring you are using the most current stable versions and following the template please. You can make a skeleton app for reproduction like so https://github.com/mikehardy/rnfbdemo/blob/master/make-demo.sh

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
plugin: crashlytics Firebase Crashlytics Type: Stale Issue has become stale - automatically added by Stale bot
Projects
None yet
Development

No branches or pull requests

9 participants