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 #3511

Closed
6 tasks
GiladR1979 opened this issue Apr 22, 2020 · 3 comments
Closed
6 tasks
Labels
plugin: crashlytics Firebase Crashlytics

Comments

@GiladR1979
Copy link

GiladR1979 commented Apr 22, 2020

Opened a new issue since this was closed
Here

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


@russellwheatley
Copy link
Member

Could you please fill out the rest of the template, please?

@GiladR1979
Copy link
Author

GiladR1979 commented May 10, 2020

Could you please fill out the rest of the template, please?

@russellwheatley
Filled the rest, without some company related code.

@russellwheatley
Copy link
Member

Hi @GiladR1979 , I've just noticed you've opened an issue for the same problem which has not been closed. Therefore, I'll be closing this one and redirecting attention to the one you initially opened. Thanks.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
plugin: crashlytics Firebase Crashlytics
Projects
None yet
Development

No branches or pull requests

2 participants