microsoft / appcenter-sdk-react-native

Development repository for the App Center SDK for React Native
Other
411 stars 135 forks source link

TypeError: null is not an object (evaluating 'AppCenterReactNativeAnalytics.trackEvent') #666

Closed ldco2016 closed 4 years ago

ldco2016 commented 5 years ago

Description

When I boot up my application on android and then click on the login button, I get the following error:

TypError: null is not an object (evaluating 'AppCenterReactNativeAnalytics.trackEvent')

This only happens in android.

Repro Steps

Please list the steps used to reproduce your issue.

  1. I run react-native run-android --variant=DevDebug

Details

  1. Which version of the App Center SDK are you using? 2.2.0
  2. Which OS version did you experience the issue on?
OS: macOS High Sierra 10.13.6, 
SDKs:
    iOS SDK:
      Platforms: iOS 12.1, macOS 10.14, tvOS 12.1, watchOS 5.1
    Android SDK:
      API Levels: 23, 25, 26, 27, 28
      Build Tools: 23.0.1, 26.0.2, 27.0.3, 28.0.3
      System Images: android-28 | Google Play Intel x86 Atom
  1. What device version did you see this error on? Were you using an emulator or a physical device?

    Nexus 5x android emulator

  2. What third party libraries are you using?

 },
  "dependencies": {
    "@react-native-community/async-storage": "1.5.1",
    "add": "2.0.6",
    "appcenter": "2.2.0",
    "appcenter-analytics": "2.2.0",
    "appcenter-crashes": "2.1.0",
    "axios": "0.19.0",
    "lodash": "4.17.15",
    "moment": "2.24.0",
    "payment": "2.3.0",
    "prop-types": "15.7.2",
    "react": "16.8.6",
    "react-native": "0.60.4",
    "react-native-autoheight-webview": "1.1.5",
    "react-native-calendar-events": "1.7.3",
    "react-native-device-info": "2.2.2",
    "react-native-gesture-handler": "1.3.0",
    "react-native-image-progress": "1.1.1",
    "react-native-immediate-phone-call": "1.0.0",
    "react-native-input-scroll-view": "1.9.3",
    "react-native-iphone-x-helper": "1.2.1",
    "react-native-keyboard-aware-scroll-view": "0.8.0",
    "react-native-keyboard-manager": "4.0.13-15",
    "react-native-material-buttons": "0.5.0",
    "react-native-material-dropdown": "0.11.1",
    "react-native-material-tabs": "3.8.1",
    "react-native-material-textfield": "0.12.0",
    "react-native-onesignal": "3.2.14",
    "react-native-popup-menu": "0.15.6",
    "react-native-reanimated": "1.1.0",
    "react-native-sentry": "0.43.2",
    "react-native-size-matters": "0.2.1",
    "react-native-splash-screen": "3.2.0",
    "react-native-svg": "9.5.3",
    "react-native-swipe-view": "3.0.1",
    "react-native-vector-icons": "6.6.0",
    "react-native-webview": "5.12.1",
    "react-navigation": "1.5.11",
    "react-redux": "5.1.1",
    "reactotron-react-native": "3.6.4",
    "reactotron-redux": "3.1.1",
    "recompose": "0.30.0",
    "redux": "4.0.4",
    "redux-thunk": "2.3.0",
    "replace-in-file": "4.1.1"
  },
  1. Run the following command and paste the output below: react-native info
System:
    OS: macOS High Sierra 10.13.6
    CPU: (8) x64 Intel(R) Core(TM) i7-4770HQ CPU @ 2.20GHz
    Memory: 290.97 MB / 16.00 GB
    Shell: 5.3 - /bin/zsh
  Binaries:
    Node: 11.10.1 - /usr/local/bin/node
    Yarn: 1.10.1 - /usr/local/bin/yarn
    npm: 6.7.0 - /usr/local/bin/npm
    Watchman: 4.7.0 - /usr/local/bin/watchman
  SDKs:
    iOS SDK:
      Platforms: iOS 12.1, macOS 10.14, tvOS 12.1, watchOS 5.1
    Android SDK:
      API Levels: 23, 25, 26, 27, 28
      Build Tools: 23.0.1, 26.0.2, 27.0.3, 28.0.3
      System Images: android-28 | Google Play Intel x86 Atom
  IDEs:
    Android Studio: 3.4 AI-183.5429.30.34.5452501
    Xcode: 10.1/10B61 - /usr/bin/xcodebuild
  npmPackages:
    react: 16.8.6 => 16.8.6
    react-native: 0.60.4 => 0.60.4
  npmGlobalPackages:
    react-native-cli: 2.0.1
    react-native-git-upgrade: 0.2.7
  1. If you're developing for React Native iOS, run the following command and paste the output below: pod --version

1.7.1

  1. Please enable verbose logging for your app using [MSAppCenter setLogLevel: MSLogLevelVerbose]; before your call to [AppCenterReactNative register]; (or any other SDK registration). For Android, use AppCenter.setLogLevel(android.util.Log.VERBOSE); before your SoLoader.init call. Include the logs here:
2019-08-12 11:56:35.641 10338-11742/com.nfibengage W/unknown:ReactNative: Calling JS function after bridge has been destroyed: RCTDeviceEventEmitter.emit(["Sentry/eventSentSuccessfully",{"tags":{},"extra":{"session:duration":4270},"dist":"1","release":"com.nfibengage-1.0","message":"TypeError: null is not an object (evaluating 'AppCenterReactNativeAnalytics.trackEvent')\n\nThis error is located at:\n    in NavigationContainer (at RootNavigation.js:216)\n    in RootNavigation (created by Connect(RootNavigation))\n    in Connect(RootNavigation) (at App.js:249)\n    in RCTView (at View.js:35)\n    in View (at App.js:247)\n    in Provider (at App.js:246)\n    in NFIBEngage (at renderApplication.js:40)\n    in RCTView (at View.js:35)\n    in View (at AppContainer.js:98)\n    in RCTView (at View.js:35)\n    in View (at AppContainer.js:115)\n    in AppContainer (at renderApplication.js:39)","level":"fatal","event_id":"da1e100d-1d53-46a1-87e7-05b765f148b2"}])
2019-08-12 13:28:45.946 10338-12712/com.nfibengage W/ReactNativeJS: Require cycle: src/services/Requester.js -> src/utils/appcenterLogger.js -> src/services/Requester.js

    Require cycles are allowed, but can result in uninitialized values. Consider refactoring to remove the need for a cycle.
2019-08-12 13:28:50.146 10338-12712/com.nfibengage E/ReactNativeJS: TypeError: null is not an object (evaluating 'AppCenterReactNativeAnalytics.trackEvent')
annakocheshkova commented 5 years ago

Hi @ldco2016. I see that you are referencing a similar issue, I'm assuming all the solutions listed there did not help? I see that you are using react-native 0.60. They introduced autolinking so I would like to know several things.

  1. Did you add our module before or after upgrading to react-native 0.60?
  2. Do you see the following code inside PackageList.java > public ArrayList<ReactPackage> getPackages()?
    new AppCenterReactNativePackage(getApplication()),
    new AppCenterReactNativeAuthPackage(getApplication())
  3. Do you see module imports inside settings.gradle?
  4. Could you share the code you are using? I see some messages about require cycles which can lead to NPEs.
ldco2016 commented 5 years ago

Hi @annakocheshkova ,

  1. I added your module after upgrading to RN 60.4.
  2. This is the code I have inside of android/app/src/main/java/com/nfibengage/MainApplication.java:
package com.nfibengage;

import android.app.Application;
import android.util.Log;

import com.facebook.react.PackageList;
import com.facebook.hermes.reactexecutor.HermesExecutorFactory;
import com.facebook.react.bridge.JavaScriptExecutorFactory;
import com.facebook.react.ReactApplication;
import com.learnium.RNDeviceInfo.RNDeviceInfo;
import com.microsoft.appcenter.reactnative.crashes.AppCenterReactNativeCrashesPackage;
import com.microsoft.appcenter.reactnative.analytics.AppCenterReactNativeAnalyticsPackage;
import com.microsoft.appcenter.reactnative.appcenter.AppCenterReactNativePackage;
import com.geektime.rnonesignalandroid.ReactNativeOneSignalPackage;
import io.sentry.RNSentryPackage;
import com.reactnativecommunity.webview.RNCWebViewPackage;
import com.facebook.react.ReactNativeHost;
import com.facebook.react.ReactPackage;
import com.facebook.soloader.SoLoader;
import com.github.wumke.RNImmediatePhoneCall.RNImmediatePhoneCallPackage;

import java.util.List;

public class MainApplication extends Application implements ReactApplication {

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

    @Override
    protected List<ReactPackage> getPackages() {
      @SuppressWarnings("UnnecessaryLocalVariable")
      List<ReactPackage> packages = new PackageList(this).getPackages();
      // Packages that cannot be autolinked yet can be added manually here, for example:
      // packages.add(new MyReactNativePackage());
      packages.add(new AppCenterReactNativeCrashesPackage(MainApplication.this, getResources().getString(R.string.appCenterCrashes_whenToSendCrashes)));
      packages.add(new AppCenterReactNativeAnalyticsPackage(MainApplication.this, getResources().getString(R.string.appCenterAnalytics_whenToEnableAnalytics)));
      packages.add(new AppCenterReactNativePackage(MainApplication.this));
      packages.add(new ReactNativeOneSignalPackage());
      packages.add(new RNSentryPackage());
      packages.add(new RNDeviceInfo());
      packages.add(new RNImmediatePhoneCallPackage());
      return packages;
    }

This is my settings.gradle:

rootProject.name = 'NFIBEngage'
include ':react-native-device-info'
project(':react-native-device-info').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-device-info/android')
include ':appcenter-crashes'
project(':appcenter-crashes').projectDir = new File(rootProject.projectDir, '../node_modules/appcenter-crashes/android')
include ':appcenter-analytics'
project(':appcenter-analytics').projectDir = new File(rootProject.projectDir, '../node_modules/appcenter-analytics/android')
include ':appcenter'
project(':appcenter').projectDir = new File(rootProject.projectDir, '../node_modules/appcenter/android')
include ':react-native-onesignal'
project(':react-native-onesignal').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-onesignal/android')
include ':react-native-sentry'
project(':react-native-sentry').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-sentry/android')
include ':react-native-immediate-phone-call'
project(':react-native-immediate-phone-call').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-immediate-phone-call/android')
include ':react-native-webview'
project(':react-native-webview').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-webview/android')
apply from: file("../node_modules/@react-native-community/cli-platform-android/native_modules.gradle"); applyNativeModulesSettingsGradle(settings)
include ':app'

This is a message I saw in the logcat console of Android Studio:

2019-08-12 11:56:35.641 10338-11742/com.nfibengage W/unknown:ReactNative: Calling JS function after bridge has been destroyed: RCTDeviceEventEmitter.emit(["Sentry/eventSentSuccessfully",{"tags":{},"extra":{"session:duration":4270},"dist":"1","release":"com.nfibengage-1.0","message":"TypeError: null is not an object (evaluating 'AppCenterReactNativeAnalytics.trackEvent')\n\nThis error is located at:\n    in NavigationContainer (at RootNavigation.js:216)\n    in RootNavigation (created by Connect(RootNavigation))\n    in Connect(RootNavigation) (at App.js:249)\n    in RCTView (at View.js:35)\n    in View (at App.js:247)\n    in Provider (at App.js:246)\n    in NFIBEngage (at renderApplication.js:40)\n    in RCTView (at View.js:35)\n    in View (at AppContainer.js:98)\n    in RCTView (at View.js:35)\n    in View (at AppContainer.js:115)\n    in AppContainer (at renderApplication.js:39)","level":"fatal","event_id":"da1e100d-1d53-46a1-87e7-05b765f148b2"}])
2019-08-12 13:28:45.946 10338-12712/com.nfibengage W/ReactNativeJS: Require cycle: src/services/Requester.js -> src/utils/appcenterLogger.js -> src/services/Requester.js

    Require cycles are allowed, but can result in uninitialized values. Consider refactoring to remove the need for a cycle.
2019-08-12 13:28:50.146 10338-12712/com.nfibengage E/ReactNativeJS: TypeError: null is not an object (evaluating 'AppCenterReactNativeAnalytics.trackEvent')

I am importing the Analytics module in my src/utils/appcenterLogger.js file:

import Analytics from "appcenter-analytics";
import * as requester from "services/Requester";
import * as endpoints from "endpoints";

async function getOrgData(individual) {
  if (individual.Organization) {
    const { Key } = individual.Organization;
    const organizationData = await requester.sendGet(
      `${endpoints.ORGANIZATION}/${Key}`
    );
    const businessZip = organizationData.Addresses.reduce(
      (acc, curr) => `${acc}, ${curr}`,
      ""
    );
    const { PersonalAddress } = individual;
    //prettier-ignore
    const homeZip = PersonalAddress && PersonalAddress.PostalCode ? PersonalAddress : '';
    return {
      businessZip,
      homeZip
    };
  }

  return {
    businessZip: "",
    homeZip: ""
  };
}

export async function trackUser(event, individual, IsLoggedIn) {
  try {
    const data = await getOrgData(individual);
    Analytics.trackEvent(event, {
      Guid: `${individual.Key}`,
      Email: `${individual.ContactDetails.EmailAddress}`,
      BusinessZip: data.businessZip,
      HomeZiP: data.homeZip,
      IsLoggedIn
    });
  } catch (e) {
    return false;
  }
}

export function trackAppOpened() {
  Analytics.trackEvent("AppOpen");
}

export function trackAppBackgrounding() {
  Analytics.trackEvent("AppBackground");
}

export function trackNavigation(from, to) {
  Analytics.trackEvent("AppNavigation", { from, to });
}

export function trackRequestTiming(sent, received) {
  Analytics.trackEvent("RequestSent", {
    sent: `${sent}`,
    received: `${received}`
  });
}
annakocheshkova commented 5 years ago

@ldco2016 My guess is that you have a cycle reference betweeen Requester.js and appcenterLogger.js, at least that's what the error implies. Could you check that first and if it doesn't solve the issue, I will have to find a way to reproduce this behavior.

ldco2016 commented 5 years ago

@annakocheshkova , I have tried commenting out in such a way to break the requester cycle, but I am not sure if I did this correctly.

In `src/services/Requester.js:

import axios from "axios";
import LocalStorage from "./LocalStorage";
import env from "env";
// import * as appcenter from "utils/appcenterLogger";
import * as titlesHelper from "utils/titleCaser";

let expired = false;

export const instance = axios.create({
  headers: {
    Accept: "application/json",
    "Content-Type": "application/json",
    NFIBAppID: env.NFIBAppID
  }
});

let preHeaders = {};
async function mergeConfig(config) {
  try {
    const access = await LocalStorage.get("access");
    preHeaders = access;
    return { ...config, headers: { ...access } };
  } catch (error) {
    return { ...config };
  }
}

export async function sendGet(url, config = {}) {
  if (expired) {
    return;
  }

  const now = new Date();

  return instance
    .get(url, await mergeConfig(config))
    .then(response => {
      return saveHeaders(response, now);
    })
    .catch(error => {
      return catchErros(error, now);
    });
}

export async function sendPost(url, data, config = {}) {
  if (expired) {
    return;
  }

  const now = new Date();
  return instance
    .post(url, titlesHelper.lowerCaser(data), await mergeConfig(config))
    .then(response => {
      return saveHeaders(response, now);
    })
    .catch(error => {
      return catchErros(error, now);
    });
}
export async function sendPut(url, data, config = {}) {
  if (expired) {
    return;
  }

  const now = new Date();
  return instance
    .put(url, titlesHelper.lowerCaser(data), await mergeConfig(config))
    .then(response => {
      return saveHeaders(response, now);
    })
    .catch(error => {
      return catchErros(error, now);
    });
}
export async function sendPatch(url, data, config = {}) {
  if (expired) {
    return;
  }

  const now = new Date();
  return instance
    .patch(url, data, await mergeConfig(config))
    .then(response => {
      return saveHeaders(response, now);
    })
    .catch(error => {
      return catchErros(error, now);
    });
}
export async function sendDelete(url, data, config = {}) {
  if (expired) {
    return;
  }

  const now = new Date();
  return instance
    .delete(url, await mergeConfig(config))
    .then(response => {
      return saveHeaders(response, now);
    })
    .catch(error => {
      return catchErros(error, now);
    });
}

export function saveHeaders({ data, headers }, timeSent) {
  try {
    if (headers && headers.authorizationtoken) {
      LocalStorage.save("access", {
        AuthorizationToken: headers.authorizationtoken
      });
    }
    const timeReceived = new Date();
    LocalStorage.save("lastTimeRequestSent", timeReceived);
    appcenter.trackRequestTiming(timeSent, timeReceived);
    return titlesHelper.toTitleCase(data);
  } catch (_e) {
    return false;
  }
}

function catchErros(error, timeSent) {
  try {
    const timeReceived = new Date();
    LocalStorage.save("lastTimeRequestSent", timeReceived);
    appcenter.trackRequestTiming(timeSent, timeReceived);

    if (error && error.response) {
      saveHeaders({
        headers: preHeaders
      });

      const { data } = error.response;
      const message = data.message || data.Message;
      if (message.includes("TokenExpired")) {
        expired = true;
      }
    }
    return Promise.reject(titlesHelper.toTitleCase(error.response.data));
  } catch (_e) {
    return error;
  }
}

export function resetTokenExpired() {
  expired = false;
}

In src/utils/appcenterLogger.js:

import Analytics from "appcenter-analytics";
// import * as requester from "services/Requester";
import * as endpoints from "endpoints";

// async function getOrgData(individual) {
//   if (individual.Organization) {
//     const { Key } = individual.Organization;
//     const organizationData = await requester.sendGet(
//       `${endpoints.ORGANIZATION}/${Key}`
//     );
//     const businessZip = organizationData.Addresses.reduce(
//       (acc, curr) => `${acc}, ${curr}`,
//       ""
//     );
//     const { PersonalAddress } = individual;
//     //prettier-ignore
//     const homeZip = PersonalAddress && PersonalAddress.PostalCode ? PersonalAddress : '';
//     return {
//       businessZip,
//       homeZip
//     };
//   }
//
//   return {
//     businessZip: "",
//     homeZip: ""
//   };
// }

export async function trackUser(event, individual, IsLoggedIn) {
  try {
    const data = await getOrgData(individual);
    Analytics.trackEvent(event, {
      Guid: `${individual.Key}`,
      Email: `${individual.ContactDetails.EmailAddress}`,
      BusinessZip: data.businessZip,
      HomeZiP: data.homeZip,
      IsLoggedIn
    });
  } catch (e) {
    return false;
  }
}

export function trackAppOpened() {
  Analytics.trackEvent("AppOpen");
}

export function trackAppBackgrounding() {
  Analytics.trackEvent("AppBackground");
}

export function trackNavigation(from, to) {
  Analytics.trackEvent("AppNavigation", { from, to });
}

export function trackRequestTiming(sent, received) {
  Analytics.trackEvent("RequestSent", {
    sent: `${sent}`,
    received: `${received}`
  });
}

Was this a sensible approach? If so, I still get the same error when I click on Login button.

annakocheshkova commented 5 years ago

Looks like so @ldco2016. Are you still getting the same "Require cycle" error or just the first one? Could you also check if App Center libraries are pulled correctly from node_modules folder?

ldco2016 commented 5 years ago

@annakocheshkova ,

I only get the AppCenterReactNativeAnalytics error in logcat:

2019-08-13 09:59:29.435 10338-10368/com.nfibengage D/EGL_emulation: eglMakeCurrent: 0xe44ddce0: ver 3 0 (tinfo 0xdfa6ba10)
2019-08-13 09:59:29.856 10338-12722/com.nfibengage W/unknown:ReactNative: Calling JS function after bridge has been destroyed: RCTDeviceEventEmitter.emit(["Sentry/eventStored",{}])
2019-08-13 09:59:29.856 10338-12722/com.nfibengage W/unknown:ReactNative: Calling JS function after bridge has been destroyed: RCTDeviceEventEmitter.emit(["Sentry/eventSentSuccessfully",{"tags":{},"extra":{"session:duration":70447},"dist":"1","release":"com.nfibengage-1.0","message":"TypeError: null is not an object (evaluating 'AppCenterReactNativeAnalytics.trackEvent')\n\nThis 

I also did a console log on:

import Analytics from "appcenter-analytics";
console.log(Analytics);

and this is what I get:

Object
PropertyConfigurator: ƒ _class(transmissionTarget)
TransmissionTarget: ƒ _class2(targetToken)
bindingType: "MSAnalytics"
getTransmissionTarget: ƒ getTransmissionTarget(targetToken)
isEnabled: ƒ isEnabled()
setEnabled: ƒ setEnabled(enabled)
trackEvent: ƒ trackEvent(eventName, properties)
arguments: null
caller: null
length: 2
name: "trackEvent"
prototype: {constructor: ƒ}
__proto__: ƒ ()
[[FunctionLocation]]: Analytics.js:8
[[Scopes]]: Scopes[2]
__proto__: Object

So it is importing it correctly. It is an object or is it referencing the arguments property out of Analytics as what is null?

Let me know if providing you a copy of the application can help you, help me.

annakocheshkova commented 5 years ago

@ldco2016 could you send the full verbose logs from the start of the app? Although looks like Analytics object does exist, it may have encountered some problems during initialization.

ldco2016 commented 5 years ago

@annakocheshkova

From my Reactotron logs this is what it says:

TypeError: null is not an object (evaluating 'AppCenterReactNativeAnalytics.trackEvent') This error is located at: in NavigationContainer (at RootNavigation.js:216) in RootNavigation (created by Connect(RootNavigation)) in Connect(RootNavigation) (at App.js:247) in RCTView (at View.js:35) in View (at App.js:245) in Provider (at App.js:244) in NFIBEngage (at renderApplication.js:40) in RCTView (at View.js:35) in View (at AppContainer.js:98) in RCTView (at View.js:35) in View (at AppContainer.js:115) in AppContainer (at renderApplication.js:39)

In Android Studio logcat I get the same stacktrace:

2019-08-14 11:47:03.279 10338-12722/com.nfibengage W/unknown:ReactNative: Calling JS function after bridge has been destroyed: RCTDeviceEventEmitter.emit(["Sentry/eventSentSuccessfully",{"tags":{},"extra":{"session:duration":44672},"dist":"1","release":"com.nfibengage-1.0","message":"TypeError: null is not an object (evaluating 'AppCenterReactNativeAnalytics.trackEvent')\n\nThis error is located at:\n    in NavigationContainer (at RootNavigation.js:216)\n    in RootNavigation (created by Connect(RootNavigation))\n    in Connect(RootNavigation) (at App.js:247)\n    in RCTView (at View.js:35)\n    in View (at App.js:245)\n    in Provider (at App.js:244)\n    in NFIBEngage (at renderApplication.js:40)\n    in RCTView (at View.js:35)\n    in View (at AppContainer.js:98)\n    in RCTView (at View.js:35)\n    in View (at AppContainer.js:115)\n    in AppContainer (at renderApplication.js:39)","level":"fatal","event_id":"0174859d-b63d-4be5-94b6-5da9629fa9ed"}])
2019-08-14 11:49:29.951 10338-19397/com.nfibengage E/ReactNativeJS: TypeError: null is not an object (evaluating 'AppCenterReactNativeAnalytics.trackEvent')

    This error is located at:
        in NavigationContainer (at RootNavigation.js:216)
        in RootNavigation (created by Connect(RootNavigation))
        in Connect(RootNavigation) (at App.js:247)
        in RCTView (at View.js:35)
        in View (at App.js:245)
        in Provider (at App.js:244)
        in NFIBEngage (at renderApplication.js:40)
        in RCTView (at View.js:35)
        in View (at AppContainer.js:98)
        in RCTView (at View.js:35)
        in View (at AppContainer.js:115)
        in AppContainer (at renderApplication.js:39)
2019-08-14 11:49:30.250 10338-10528/com.nfibengage W/unknown:ReactNative: Calling JS function after bridge has been destroyed: RCTDeviceEventEmitter.emit(["Sentry/eventSentSuccessfully",{"tags":{},"extra":{"session:duration":4164},"dist":"1","release":"com.nfibengage-1.0","message":"TypeError: null is not an object (evaluating 'AppCenterReactNativeAnalytics.trackEvent')\n\nThis error is located at:\n    in NavigationContainer (at RootNavigation.js:216)\n    in RootNavigation (created by Connect(RootNavigation))\n    in Connect(RootNavigation) (at App.js:247)\n    in RCTView (at View.js:35)\n    in View (at App.js:245)\n    in Provider (at App.js:244)\n    in NFIBEngage (at renderApplication.js:40)\n    in RCTView (at View.js:35)\n    in View (at AppContainer.js:98)\n    in RCTView (at View.js:35)\n    in View (at AppContainer.js:115)\n    in AppContainer (at renderApplication.js:39)","level":"fatal","event_id":"a6414a2e-d7ad-40c7-ac77-7b7642d8245c"}])
annakocheshkova commented 5 years ago

@ldco2016 I need the full logs from App Center from logcat. Basically all that happened before that. Btw did you call AppCenter.setLogLevel(android.util.Log.VERBOSE); ?

ldco2016 commented 5 years ago

@annakocheshkova , I just added the above line of code to the MainApplication.java file right above SoLoader.init(this, /* native exopackage */ false); and this is the printout from logcat:

2019-08-14 14:41:54.430 10338-10368/com.nfibengage D/EGL_emulation: eglMakeCurrent: 0xe44ddce0: ver 3 0 (tinfo 0xdfa6ba10)
2019-08-14 14:41:54.443 10338-10368/com.nfibengage D/EGL_emulation: eglMakeCurrent: 0xe44ddce0: ver 3 0 (tinfo 0xdfa6ba10)
2019-08-14 14:41:55.354 10338-11742/com.nfibengage W/unknown:ReactNative: Calling JS function after bridge has been destroyed: RCTDeviceEventEmitter.emit(["Sentry/eventStored",{}])
2019-08-14 14:41:55.354 10338-11742/com.nfibengage W/unknown:ReactNative: Calling JS function after bridge has been destroyed: RCTDeviceEventEmitter.emit(["Sentry/eventSentSuccessfully",{"tags":{},"extra":{"session:duration":4648},"dist":"1","release":"com.nfibengage-1.0","message":"TypeError: null is not an object (evaluating 'AppCenterReactNativeAnalytics.trackEvent')\n\nThis error is located at:\n    in NavigationContainer (at RootNavigation.js:216)\n    in RootNavigation (created by Connect(RootNavigation))\n    in Connect(RootNavigation) (at App.js:247)\n    in RCTView (at View.js:35)\n    in View (at App.js:245)\n    in Provider (at App.js:244)\n    in NFIBEngage (at renderApplication.js:40)\n    in RCTView (at View.js:35)\n    in View (at AppContainer.js:98)\n    in RCTView (at View.js:35)\n    in View (at AppContainer.js:115)\n    in AppContainer (at renderApplication.js:39)","level":"fatal","event_id":"d233756d-e016-4b54-ab35-d8bd6e1a196b"}])
2019-08-14 14:41:55.972 10338-10368/com.nfibengage D/EGL_emulation: eglMakeCurrent: 0xe44ddce0: ver 3 0 (tinfo 0xdfa6ba10)
2019-08-14 14:44:08.461 10338-10368/com.nfibengage D/EGL_emulation: eglMakeCurrent: 0xe44ddce0: ver 3 0 (tinfo 0xdfa6ba10)
2019-08-14 14:44:08.549 10338-10368/com.nfibengage D/EGL_emulation: eglMakeCurrent: 0xe44ddce0: ver 3 0 (tinfo 0xdfa6ba10)
2019-08-14 14:44:09.124 10338-10368/com.nfibengage D/EGL_emulation: eglMakeCurrent: 0xe44ddce0: ver 3 0 (tinfo 0xdfa6ba10)
2019-08-14 14:44:09.133 10338-10338/com.nfibengage D/ReactNative: ReactInstanceManager.onJSBundleLoadedFromServer()
2019-08-14 14:44:09.133 10338-10338/com.nfibengage D/ReactNative: ReactInstanceManager.recreateReactContextInBackground()
2019-08-14 14:44:09.133 10338-10338/com.nfibengage D/ReactNative: ReactInstanceManager.runCreateReactContextOnNewThread()
2019-08-14 14:44:09.134 10338-10338/com.nfibengage D/ReactNative: ReactInstanceManager.tearDownReactContext()
2019-08-14 14:44:09.138 10338-10338/com.nfibengage D/ReactNative: CatalystInstanceImpl.destroy() start
2019-08-14 14:44:09.138 10338-10338/com.nfibengage W/unknown:ReactNative: Packager connection already open, nooping.
2019-08-14 14:44:09.140 10338-10368/com.nfibengage D/EGL_emulation: eglMakeCurrent: 0xe44ddce0: ver 3 0 (tinfo 0xdfa6ba10)
2019-08-14 14:44:09.140 10338-22201/com.nfibengage D/ReactNative: ReactInstanceManager.createReactContext()
2019-08-14 14:44:09.173 10338-22201/com.nfibengage D/ReactNative: Initializing React Xplat Bridge.
2019-08-14 14:44:09.185 10338-22201/com.nfibengage D/ReactNative: Initializing React Xplat Bridge before initializeBridge
2019-08-14 14:44:09.189 10338-22201/com.nfibengage D/ReactNative: Initializing React Xplat Bridge after initializeBridge
2019-08-14 14:44:09.189 10338-22201/com.nfibengage D/ReactNative: CatalystInstanceImpl.runJSBundle()
2019-08-14 14:44:09.190 10338-22203/com.nfibengage D/ReactNative: ReactInstanceManager.setupReactContext()
2019-08-14 14:44:09.190 10338-22203/com.nfibengage D/ReactNative: CatalystInstanceImpl.initialize()
2019-08-14 14:44:09.192 10338-10338/com.nfibengage W/unknown:ReactNative: Packager connection already open, nooping.
2019-08-14 14:44:09.193 10338-22203/com.nfibengage D/ReactNative: ReactInstanceManager.attachRootViewToInstance()
2019-08-14 14:44:09.195 10338-22203/com.nfibengage W/unknown:ViewManagerPropertyUpdater: Could not find generated setter for class com.facebook.react.views.art.ARTGroupViewManager
2019-08-14 14:44:09.197 10338-22203/com.nfibengage W/unknown:ViewManagerPropertyUpdater: Could not find generated setter for class com.facebook.react.views.art.ARTGroupShadowNode
2019-08-14 14:44:09.198 10338-22203/com.nfibengage W/unknown:ViewManagerPropertyUpdater: Could not find generated setter for class com.facebook.react.views.art.ARTShapeViewManager
2019-08-14 14:44:09.198 10338-22203/com.nfibengage W/unknown:ViewManagerPropertyUpdater: Could not find generated setter for class com.facebook.react.views.art.ARTShapeShadowNode
2019-08-14 14:44:09.198 10338-22203/com.nfibengage W/unknown:ViewManagerPropertyUpdater: Could not find generated setter for class com.facebook.react.views.art.ARTTextViewManager
2019-08-14 14:44:09.198 10338-22203/com.nfibengage W/unknown:ViewManagerPropertyUpdater: Could not find generated setter for class com.facebook.react.views.art.ARTTextShadowNode
2019-08-14 14:44:09.199 10338-22203/com.nfibengage W/unknown:ViewManagerPropertyUpdater: Could not find generated setter for class com.facebook.react.views.checkbox.ReactCheckBoxManager
2019-08-14 14:44:09.202 10338-22203/com.nfibengage W/unknown:ViewManagerPropertyUpdater: Could not find generated setter for class com.facebook.react.uimanager.LayoutShadowNode
2019-08-14 14:44:09.204 10338-22203/com.nfibengage W/unknown:ViewManagerPropertyUpdater: Could not find generated setter for class com.facebook.react.views.picker.ReactDialogPickerManager
2019-08-14 14:44:09.206 10338-22203/com.nfibengage W/unknown:ViewManagerPropertyUpdater: Could not find generated setter for class com.facebook.react.views.drawer.ReactDrawerLayoutManager
2019-08-14 14:44:09.207 10338-22203/com.nfibengage W/unknown:ViewManagerPropertyUpdater: Could not find generated setter for class com.facebook.react.views.picker.ReactDropdownPickerManager
2019-08-14 14:44:09.207 10338-22203/com.nfibengage W/unknown:ViewManagerPropertyUpdater: Could not find generated setter for class com.facebook.react.views.scroll.ReactHorizontalScrollViewManager
2019-08-14 14:44:09.209 10338-22203/com.nfibengage W/unknown:ViewManagerPropertyUpdater: Could not find generated setter for class com.facebook.react.views.scroll.ReactHorizontalScrollContainerViewManager
2019-08-14 14:44:09.210 10338-22203/com.nfibengage W/unknown:ViewManagerPropertyUpdater: Could not find generated setter for class com.facebook.react.views.progressbar.ReactProgressBarViewManager
2019-08-14 14:44:09.212 10338-22203/com.nfibengage W/unknown:ViewManagerPropertyUpdater: Could not find generated setter for class com.facebook.react.views.progressbar.ProgressBarShadowNode
2019-08-14 14:44:09.213 10338-22203/com.nfibengage W/unknown:ViewManagerPropertyUpdater: Could not find generated setter for class com.facebook.react.views.scroll.ReactScrollViewManager
2019-08-14 14:44:09.213 10338-22203/com.nfibengage W/unknown:ViewManagerPropertyUpdater: Could not find generated setter for class com.facebook.react.views.slider.ReactSliderManager
2019-08-14 14:44:09.214 10338-22203/com.nfibengage W/unknown:ViewManagerPropertyUpdater: Could not find generated setter for class com.facebook.react.views.slider.ReactSliderManager$ReactSliderShadowNode
2019-08-14 14:44:09.214 10338-22203/com.nfibengage W/unknown:ViewManagerPropertyUpdater: Could not find generated setter for class com.facebook.react.views.switchview.ReactSwitchManager
2019-08-14 14:44:09.214 10338-22203/com.nfibengage W/unknown:ViewManagerPropertyUpdater: Could not find generated setter for class com.facebook.react.views.switchview.ReactSwitchManager$ReactSwitchShadowNode
2019-08-14 14:44:09.214 10338-22203/com.nfibengage W/unknown:ViewManagerPropertyUpdater: Could not find generated setter for class com.facebook.react.views.toolbar.ReactToolbarManager
2019-08-14 14:44:09.215 10338-22203/com.nfibengage W/unknown:ViewManagerPropertyUpdater: Could not find generated setter for class com.facebook.react.views.swiperefresh.SwipeRefreshLayoutManager
2019-08-14 14:44:09.216 10338-22203/com.nfibengage W/unknown:ViewManagerPropertyUpdater: Could not find generated setter for class com.facebook.react.views.art.ARTSurfaceViewManager
2019-08-14 14:44:09.216 10338-22203/com.nfibengage W/unknown:ViewManagerPropertyUpdater: Could not find generated setter for class com.facebook.react.views.art.ARTSurfaceViewShadowNode
2019-08-14 14:44:09.216 10338-22203/com.nfibengage W/unknown:ViewManagerPropertyUpdater: Could not find generated setter for class com.facebook.react.views.text.frescosupport.FrescoBasedReactTextInlineImageViewManager
2019-08-14 14:44:09.216 10338-22203/com.nfibengage W/unknown:ViewManagerPropertyUpdater: Could not find generated setter for class com.facebook.react.views.text.frescosupport.FrescoBasedReactTextInlineImageShadowNode
2019-08-14 14:44:09.216 10338-22203/com.nfibengage W/unknown:ViewManagerPropertyUpdater: Could not find generated setter for class com.facebook.react.views.image.ReactImageManager
2019-08-14 14:44:09.217 10338-22203/com.nfibengage W/unknown:ViewManagerPropertyUpdater: Could not find generated setter for class com.facebook.react.views.modal.ReactModalHostManager
2019-08-14 14:44:09.217 10338-22203/com.nfibengage W/unknown:ViewManagerPropertyUpdater: Could not find generated setter for class com.facebook.react.views.modal.ModalHostShadowNode
2019-08-14 14:44:09.217 10338-22203/com.nfibengage W/unknown:ViewManagerPropertyUpdater: Could not find generated setter for class com.facebook.react.views.text.ReactRawTextManager
2019-08-14 14:44:09.218 10338-22203/com.nfibengage W/unknown:ViewManagerPropertyUpdater: Could not find generated setter for class com.facebook.react.views.text.ReactRawTextShadowNode
2019-08-14 14:44:09.219 10338-22203/com.nfibengage W/unknown:ViewManagerPropertyUpdater: Could not find generated setter for class com.facebook.react.views.textinput.ReactTextInputManager
2019-08-14 14:44:09.223 10338-22203/com.nfibengage W/unknown:ViewManagerPropertyUpdater: Could not find generated setter for class com.facebook.react.views.textinput.ReactTextInputShadowNode
2019-08-14 14:44:09.225 10338-22203/com.nfibengage W/unknown:ViewManagerPropertyUpdater: Could not find generated setter for class com.facebook.react.views.text.ReactTextViewManager
2019-08-14 14:44:09.227 10338-22203/com.nfibengage W/unknown:ViewManagerPropertyUpdater: Could not find generated setter for class com.facebook.react.views.text.ReactTextShadowNode
2019-08-14 14:44:09.228 10338-22203/com.nfibengage W/unknown:ViewManagerPropertyUpdater: Could not find generated setter for class com.facebook.react.views.view.ReactViewManager
2019-08-14 14:44:09.232 10338-22203/com.nfibengage W/unknown:ViewManagerPropertyUpdater: Could not find generated setter for class com.facebook.react.views.viewpager.ReactViewPagerManager
2019-08-14 14:44:09.233 10338-22203/com.nfibengage W/unknown:ViewManagerPropertyUpdater: Could not find generated setter for class com.facebook.react.views.text.ReactVirtualTextViewManager
2019-08-14 14:44:09.233 10338-22203/com.nfibengage W/unknown:ViewManagerPropertyUpdater: Could not find generated setter for class com.facebook.react.views.text.ReactVirtualTextShadowNode
2019-08-14 14:44:09.234 10338-22203/com.nfibengage W/unknown:ViewManagerPropertyUpdater: Could not find generated setter for class com.swmansion.gesturehandler.react.RNGestureHandlerRootViewManager
2019-08-14 14:44:09.234 10338-22203/com.nfibengage W/unknown:ViewManagerPropertyUpdater: Could not find generated setter for class com.swmansion.gesturehandler.react.RNGestureHandlerButtonViewManager
2019-08-14 14:44:09.234 10338-22203/com.nfibengage W/unknown:ViewManagerPropertyUpdater: Could not find generated setter for class com.horcrux.svg.RenderableViewManager$GroupViewManager
2019-08-14 14:44:09.236 10338-22203/com.nfibengage W/unknown:ViewManagerPropertyUpdater: Could not find generated setter for class com.horcrux.svg.RenderableViewManager$RenderableShadowNode
2019-08-14 14:44:09.237 10338-22203/com.nfibengage W/unknown:ViewManagerPropertyUpdater: Could not find generated setter for class com.horcrux.svg.RenderableViewManager$PathViewManager
2019-08-14 14:44:09.237 10338-22203/com.nfibengage W/unknown:ViewManagerPropertyUpdater: Could not find generated setter for class com.horcrux.svg.RenderableViewManager$CircleViewManager
2019-08-14 14:44:09.238 10338-22203/com.nfibengage W/unknown:ViewManagerPropertyUpdater: Could not find generated setter for class com.horcrux.svg.RenderableViewManager$EllipseViewManager
2019-08-14 14:44:09.238 10338-22203/com.nfibengage W/unknown:ViewManagerPropertyUpdater: Could not find generated setter for class com.horcrux.svg.RenderableViewManager$LineViewManager
2019-08-14 14:44:09.239 10338-22203/com.nfibengage W/unknown:ViewManagerPropertyUpdater: Could not find generated setter for class com.horcrux.svg.RenderableViewManager$RectViewManager
2019-08-14 14:44:09.242 10338-22203/com.nfibengage W/unknown:ViewManagerPropertyUpdater: Could not find generated setter for class com.horcrux.svg.RenderableViewManager$TextViewManager
2019-08-14 14:44:09.243 10338-22203/com.nfibengage W/unknown:ViewManagerPropertyUpdater: Could not find generated setter for class com.horcrux.svg.RenderableViewManager$TSpanViewManager
2019-08-14 14:44:09.244 10338-22203/com.nfibengage W/unknown:ViewManagerPropertyUpdater: Could not find generated setter for class com.horcrux.svg.RenderableViewManager$TextPathViewManager
2019-08-14 14:44:09.252 10338-22203/com.nfibengage W/unknown:ViewManagerPropertyUpdater: Could not find generated setter for class com.horcrux.svg.RenderableViewManager$ImageViewManager
2019-08-14 14:44:09.252 10338-22203/com.nfibengage W/unknown:ViewManagerPropertyUpdater: Could not find generated setter for class com.horcrux.svg.RenderableViewManager$ClipPathViewManager
2019-08-14 14:44:09.253 10338-22203/com.nfibengage W/unknown:ViewManagerPropertyUpdater: Could not find generated setter for class com.horcrux.svg.RenderableViewManager$DefsViewManager
2019-08-14 14:44:09.253 10338-22203/com.nfibengage W/unknown:ViewManagerPropertyUpdater: Could not find generated setter for class com.horcrux.svg.RenderableViewManager$UseViewManager
2019-08-14 14:44:09.254 10338-22203/com.nfibengage W/unknown:ViewManagerPropertyUpdater: Could not find generated setter for class com.horcrux.svg.RenderableViewManager$SymbolManager
2019-08-14 14:44:09.255 10338-22203/com.nfibengage W/unknown:ViewManagerPropertyUpdater: Could not find generated setter for class com.horcrux.svg.RenderableViewManager$LinearGradientManager
2019-08-14 14:44:09.255 10338-22203/com.nfibengage W/unknown:ViewManagerPropertyUpdater: Could not find generated setter for class com.horcrux.svg.RenderableViewManager$RadialGradientManager
2019-08-14 14:44:09.256 10338-22203/com.nfibengage W/unknown:ViewManagerPropertyUpdater: Could not find generated setter for class com.horcrux.svg.RenderableViewManager$PatternManager
2019-08-14 14:44:09.259 10338-22203/com.nfibengage W/unknown:ViewManagerPropertyUpdater: Could not find generated setter for class com.horcrux.svg.RenderableViewManager$MaskManager
2019-08-14 14:44:09.261 10338-22203/com.nfibengage W/unknown:ViewManagerPropertyUpdater: Could not find generated setter for class com.horcrux.svg.SvgViewManager
2019-08-14 14:44:09.266 10338-22203/com.nfibengage W/unknown:ViewManagerPropertyUpdater: Could not find generated setter for class com.wix.RNSwipeView.SwipeViewManager
2019-08-14 14:44:09.267 10338-22203/com.nfibengage W/unknown:ViewManagerPropertyUpdater: Could not find generated setter for class com.reactnativecommunity.webview.RNCWebViewManager
2019-08-14 14:44:09.343 10338-10347/com.nfibengage W/System: A resource failed to call close. 
2019-08-14 14:44:09.586 10338-21087/com.nfibengage D/ReactNative: CatalystInstanceImpl.destroy() end
2019-08-14 14:44:10.260 10338-22202/com.nfibengage W/ReactNativeJS: Require cycle: node_modules/react-native/Libraries/Network/fetch.js -> node_modules/whatwg-fetch/dist/fetch.umd.js -> node_modules/react-native/Libraries/Network/fetch.js

    Require cycles are allowed, but can result in uninitialized values. Consider refactoring to remove the need for a cycle.
2019-08-14 14:44:10.263 10338-22202/com.nfibengage W/ReactNativeJS: Require cycle: node_modules/react-native-sentry/lib/Sentry.js -> node_modules/react-native-sentry/lib/RavenClient.js -> node_modules/react-native-sentry/lib/Sentry.js

    Require cycles are allowed, but can result in uninitialized values. Consider refactoring to remove the need for a cycle.
2019-08-14 14:44:10.427 10338-22202/com.nfibengage W/ReactNativeJS: Require cycle: src/utils/components/common/index.js -> src/utils/components/common/ModalSpinner.js -> src/utils/components/common/index.js

    Require cycles are allowed, but can result in uninitialized values. Consider refactoring to remove the need for a cycle.
2019-08-14 14:44:10.548 10338-22202/com.nfibengage W/ReactNativeJS: Warning: Invalid argument supplied to oneOfType. Expected an array of check functions, but received undefined at index 0.
2019-08-14 14:44:10.570 10338-22202/com.nfibengage W/ReactNativeJS: Require cycle: src/services/Requester.js -> src/utils/appcenterLogger.js -> src/services/Requester.js

    Require cycles are allowed, but can result in uninitialized values. Consider refactoring to remove the need for a cycle.
2019-08-14 14:44:10.982 10338-22202/com.nfibengage W/ReactNativeJS: Require cycle: src/representatives/components/index.js -> src/representatives/components/RepresentativeDetails.js -> src/representatives/components/index.js

    Require cycles are allowed, but can result in uninitialized values. Consider refactoring to remove the need for a cycle.
2019-08-14 14:44:11.170 10338-22202/com.nfibengage I/ReactNativeJS: Reactotron Configured
2019-08-14 14:44:11.174 10338-22202/com.nfibengage I/ReactNativeJS: Running application "NFIBEngage" with appParams: {"rootTag":481}. __DEV__ === true, development-level warning are ON, performance optimizations are OFF
2019-08-14 14:44:11.180 10338-17407/com.nfibengage W/unknown:ReactNative: Calling JS function after bridge has been destroyed: RCTDeviceEventEmitter.emit(["websocketMessage",{"data":"{\"type\":\"state.values.subscribe\",\"payload\":{\"paths\":[]}}","type":"text","id":1}])
2019-08-14 14:44:11.180 10338-17445/com.nfibengage W/unknown:ReactNative: Calling JS function after bridge has been destroyed: RCTDeviceEventEmitter.emit(["websocketMessage",{"data":"{\"type\":\"state.values.subscribe\",\"payload\":{\"paths\":[]}}","type":"text","id":1}])
2019-08-14 14:44:11.180 10338-19157/com.nfibengage W/unknown:ReactNative: Calling JS function after bridge has been destroyed: RCTDeviceEventEmitter.emit(["websocketMessage",{"data":"{\"type\":\"state.values.subscribe\",\"payload\":{\"paths\":[]}}","type":"text","id":1}])
2019-08-14 14:44:11.181 10338-20025/com.nfibengage W/unknown:ReactNative: Calling JS function after bridge has been destroyed: RCTDeviceEventEmitter.emit(["websocketMessage",{"data":"{\"type\":\"state.values.subscribe\",\"payload\":{\"paths\":[]}}","type":"text","id":1}])
2019-08-14 14:44:11.181 10338-19403/com.nfibengage W/unknown:ReactNative: Calling JS function after bridge has been destroyed: RCTDeviceEventEmitter.emit(["websocketMessage",{"data":"{\"type\":\"state.values.subscribe\",\"payload\":{\"paths\":[]}}","type":"text","id":1}])
2019-08-14 14:44:11.181 10338-19275/com.nfibengage W/unknown:ReactNative: Calling JS function after bridge has been destroyed: RCTDeviceEventEmitter.emit(["websocketMessage",{"data":"{\"type\":\"state.values.subscribe\",\"payload\":{\"paths\":[]}}","type":"text","id":1}])
2019-08-14 14:44:11.181 10338-19359/com.nfibengage W/unknown:ReactNative: Calling JS function after bridge has been destroyed: RCTDeviceEventEmitter.emit(["websocketMessage",{"data":"{\"type\":\"state.values.subscribe\",\"payload\":{\"paths\":[]}}","type":"text","id":1}])
2019-08-14 14:44:11.182 10338-22146/com.nfibengage W/unknown:ReactNative: Calling JS function after bridge has been destroyed: RCTDeviceEventEmitter.emit(["websocketMessage",{"data":"{\"type\":\"state.values.subscribe\",\"payload\":{\"paths\":[]}}","type":"text","id":1}])
2019-08-14 14:44:11.370 10338-22202/com.nfibengage W/ReactNativeJS: Warning: componentWillMount is deprecated and will be removed in the next major version. Use componentDidMount instead. As a temporary workaround, you can rename to UNSAFE_componentWillMount.

    Please update the following components: Container, NFIBEngage, Transitioner

    Learn more about this warning here:
    https://fb.me/react-async-component-lifecycle-hooks
2019-08-14 14:44:11.381 10338-22202/com.nfibengage W/ReactNativeJS: Warning: componentWillReceiveProps is deprecated and will be removed in the next major version. Use static getDerivedStateFromProps instead.

    Please update the following components: Button, CardStack, Connect(Intro), Connect(RootNavigation), Container, NavigationContainer, Provider, Transitioner

    Learn more about this warning here:
    https://fb.me/react-async-component-lifecycle-hooks
2019-08-14 14:44:11.385 10338-22202/com.nfibengage W/ReactNativeJS: Warning: componentWillUpdate is deprecated and will be removed in the next major version. Use componentDidUpdate instead. As a temporary workaround, you can rename to UNSAFE_componentWillUpdate.

    Please update the following components: Connect(Intro), Connect(RootNavigation)

    Learn more about this warning here:
    https://fb.me/react-async-component-lifecycle-hooks
2019-08-14 14:44:11.525 10338-22202/com.nfibengage W/ReactNativeJS: Warning: Async Storage has been extracted from react-native core and will be removed in a future release. It can now be installed and imported from '@react-native-community/async-storage' instead of 'react-native'. See https://github.com/react-native-community/react-native-async-storage
2019-08-14 14:44:11.617 10338-17445/com.nfibengage W/unknown:ReactNative: Calling JS function after bridge has been destroyed: RCTDeviceEventEmitter.emit(["websocketMessage",{"data":"{\"type\":\"storybook\",\"payload\":false}","type":"text","id":1}])
2019-08-14 14:44:11.617 10338-17407/com.nfibengage W/unknown:ReactNative: Calling JS function after bridge has been destroyed: RCTDeviceEventEmitter.emit(["websocketMessage",{"data":"{\"type\":\"storybook\",\"payload\":false}","type":"text","id":1}])
2019-08-14 14:44:11.618 10338-19157/com.nfibengage W/unknown:ReactNative: Calling JS function after bridge has been destroyed: RCTDeviceEventEmitter.emit(["websocketMessage",{"data":"{\"type\":\"storybook\",\"payload\":false}","type":"text","id":1}])
2019-08-14 14:44:11.620 10338-19275/com.nfibengage W/unknown:ReactNative: Calling JS function after bridge has been destroyed: RCTDeviceEventEmitter.emit(["websocketMessage",{"data":"{\"type\":\"storybook\",\"payload\":false}","type":"text","id":1}])
2019-08-14 14:44:11.622 10338-19359/com.nfibengage W/unknown:ReactNative: Calling JS function after bridge has been destroyed: RCTDeviceEventEmitter.emit(["websocketMessage",{"data":"{\"type\":\"storybook\",\"payload\":false}","type":"text","id":1}])
2019-08-14 14:44:11.623 10338-19403/com.nfibengage W/unknown:ReactNative: Calling JS function after bridge has been destroyed: RCTDeviceEventEmitter.emit(["websocketMessage",{"data":"{\"type\":\"storybook\",\"payload\":false}","type":"text","id":1}])
2019-08-14 14:44:11.623 10338-20025/com.nfibengage W/unknown:ReactNative: Calling JS function after bridge has been destroyed: RCTDeviceEventEmitter.emit(["websocketMessage",{"data":"{\"type\":\"storybook\",\"payload\":false}","type":"text","id":1}])
2019-08-14 14:44:11.624 10338-22146/com.nfibengage W/unknown:ReactNative: Calling JS function after bridge has been destroyed: RCTDeviceEventEmitter.emit(["websocketMessage",{"data":"{\"type\":\"storybook\",\"payload\":false}","type":"text","id":1}])
2019-08-14 14:44:13.227 10338-22202/com.nfibengage W/ReactNativeJS: Warning: componentWillReceiveProps is deprecated and will be removed in the next major version. Use static getDerivedStateFromProps instead.

    Please update the following components: Connect(Login), KeyboardAwareScrollView, Label, SafeView, TextField

    Learn more about this warning here:
    https://fb.me/react-async-component-lifecycle-hooks
2019-08-14 14:44:13.240 10338-22202/com.nfibengage W/ReactNativeJS: Warning: componentWillUpdate is deprecated and will be removed in the next major version. Use componentDidUpdate instead. As a temporary workaround, you can rename to UNSAFE_componentWillUpdate.

    Please update the following components: Connect(Login), TextField

    Learn more about this warning here:
    https://fb.me/react-async-component-lifecycle-hooks
2019-08-14 14:44:13.306 10338-22202/com.nfibengage E/ReactNativeJS: TypeError: null is not an object (evaluating 'AppCenterReactNativeAnalytics.trackEvent')

    This error is located at:
        in NavigationContainer (at RootNavigation.js:216)
        in RootNavigation (created by Connect(RootNavigation))
        in Connect(RootNavigation) (at App.js:247)
        in RCTView (at View.js:35)
        in View (at App.js:245)
        in Provider (at App.js:244)
        in NFIBEngage (at renderApplication.js:40)
        in RCTView (at View.js:35)
        in View (at AppContainer.js:98)
        in RCTView (at View.js:35)
        in View (at AppContainer.js:115)
        in AppContainer (at renderApplication.js:39)
2019-08-14 14:44:13.420 10338-10368/com.nfibengage D/EGL_emulation: eglMakeCurrent: 0xe44ddce0: ver 3 0 (tinfo 0xdfa6ba10)
2019-08-14 14:44:13.450 10338-10368/com.nfibengage D/EGL_emulation: eglMakeCurrent: 0xe44ddce0: ver 3 0 (tinfo 0xdfa6ba10)
2019-08-14 14:44:13.700 10338-12722/com.nfibengage W/unknown:ReactNative: Calling JS function after bridge has been destroyed: RCTDeviceEventEmitter.emit(["Sentry/eventStored",{}])
2019-08-14 14:44:13.700 10338-12722/com.nfibengage W/unknown:ReactNative: Calling JS function after bridge has been destroyed: RCTDeviceEventEmitter.emit(["Sentry/eventSentSuccessfully",{"tags":{},"extra":{"session:duration":3081},"dist":"1","release":"com.nfibengage-1.0","message":"TypeError: null is not an object (evaluating 'AppCenterReactNativeAnalytics.trackEvent')\n\nThis error is located at:\n    in NavigationContainer (at RootNavigation.js:216)\n    in RootNavigation (created by Connect(RootNavigation))\n    in Connect(RootNavigation) (at App.js:247)\n    in RCTView (at View.js:35)\n    in View (at App.js:245)\n    in Provider (at App.js:244)\n    in NFIBEngage (at renderApplication.js:40)\n    in RCTView (at View.js:35)\n    in View (at AppContainer.js:98)\n    in RCTView (at View.js:35)\n    in View (at AppContainer.js:115)\n    in AppContainer (at renderApplication.js:39)","level":"fatal","event_id":"0627b75c-d069-4170-be2d-0e41e38e5824"}])
2019-08-14 14:44:14.973 10338-10368/com.nfibengage D/EGL_emulation: eglMakeCurrent: 0xe44ddce0: ver 3 0 (tinfo 0xdfa6ba10)
annakocheshkova commented 5 years ago

Oh, my apologies @ldco2016 I assumed the code you pasted in the issue was after you enabled verbose, we have the instructions in the issue template. Basically, you should put the AppCenter.setLogLevel(android.util.Log.VERBOSE); before your SoLoader.init call and then send me the same output from logcat. It will contain App Center information.

ldco2016 commented 5 years ago

@annakocheshkova , I did figure out where to place AppCenter.setLogLevel(android.util.Log.VERBOSE); and what I pasted above is the logcat logs. It looks like despite the fact I edited my original post, you were responding to that old post. Did you take a look at what I have here on Github?

Furthermore, do you think this react-native.config.js file could be the source of the problem:

module.exports = {
  dependencies: {
    appcenter: {
      platforms: {
        android: null // disable Android platform, other platforms will still autolink if provided
      }
    },
    "appcenter-analytics": {
      platforms: {
        android: null // disable Android platform, other platforms will still autolink if provided
      }
    },
    "appcenter-crashes": {
      platforms: {
        android: null // disable Android platform, other platforms will still autolink if provided
      }
    }
  }
};
annakocheshkova commented 5 years ago

Oh indeed, I see your comment now. I just was confused by the logs cause they still don't contain configuration messages I was looking for. The file you mentioned can have an impact. Is this the file you have in your project? It disables autolinking for android so my guess is that you'll have to run react-native link manually then, but I can't guarantee that it will work correctly - we haven't tested this "disable autolinking" flow yet.

ldco2016 commented 5 years ago

@annakocheshkova , I did disable the react-native.config.js file and then ran react-native link, but I still get that same error message.

Any suggestions? Should I remove and reinstall everything again without the react-native.config.js file?

I will also put the AppCenter.setLogLevel(android.util.Log.VERBOSE); back in and see if I get the type of Appcenter logs you are looking for.

annakocheshkova commented 5 years ago

@ldco2016 if you disabled that file, I think you'll need to reinstall modules, but react-native link is no longer necessary. It is necessary if you want to keep react-native.config.js

ldco2016 commented 5 years ago

I disabled the file and went through the process of reinstalling the modules, but I still get the same error.

When I keep the react-native.config.js file and then do a react-native link, I still get the same error.

I added the AppCenter.setLogLevel(android.util.Log.VERBOSE); back in and tried to login again and below is the only printout from logcat:

2019-08-15 10:50:19.242 10338-12350/com.nfibengage W/ReactNativeJS: Require cycle: src/services/Requester.js -> src/utils/appcenterLogger.js -> src/services/Requester.js

    Require cycles are allowed, but can result in uninitialized values. Consider refactoring to remove the need for a cycle.
2019-08-15 10:50:22.534 10338-12350/com.nfibengage E/ReactNativeJS: TypeError: null is not an object (evaluating 'AppCenterReactNativeAnalytics.trackEvent')

    This error is located at:
        in NavigationContainer (at RootNavigation.js:216)
        in RootNavigation (created by Connect(RootNavigation))
        in Connect(RootNavigation) (at App.js:247)
        in RCTView (at View.js:35)
        in View (at App.js:245)
        in Provider (at App.js:244)
        in NFIBEngage (at renderApplication.js:40)
        in RCTView (at View.js:35)
        in View (at AppContainer.js:98)
        in RCTView (at View.js:35)
        in View (at AppContainer.js:115)
        in AppContainer (at renderApplication.js:39)
2019-08-15 10:50:23.185 10338-11447/com.nfibengage W/unknown:ReactNative: Calling JS function after bridge has been destroyed: RCTDeviceEventEmitter.emit(["Sentry/eventSentSuccessfully",{"tags":{},"extra":{"session:duration":3799},"dist":"1","release":"com.nfibengage-1.0","message":"TypeError: null is not an object (evaluating 'AppCenterReactNativeAnalytics.trackEvent')\n\nThis error is located at:\n    in NavigationContainer (at RootNavigation.js:216)\n    in RootNavigation (created by Connect(RootNavigation))\n    in Connect(RootNavigation) (at App.js:247)\n    in RCTView (at View.js:35)\n    in View (at App.js:245)\n    in Provider (at App.js:244)\n    in NFIBEngage (at renderApplication.js:40)\n    in RCTView (at View.js:35)\n    in View (at AppContainer.js:98)\n    in RCTView (at View.js:35)\n    in View (at AppContainer.js:115)\n    in AppContainer (at renderApplication.js:39)","level":"fatal","event_id":"3dfe7c1e-820c-4eab-9f90-38a7f5ce570b"}])

So I decided to comment back in appcenterLogger.js and Requester.js`, the two files with the require cycles and I am still able to click on Login without any error, but I am unable to complete login after providing credentials.

I also went ahead and commented Appcenter back into App.js file.

So to be clear, before I could not even click on the Login button which takes me to email and password form, it would go straight to error. Now I can go to email and password form from Login button, no more error, so I think the problem is either in RootNavigation.js file which it is implicated in the stacktrace I have shared with you or the problem is with loginActions.js file. As of this writing I have not tested either of those two. Could you take a look and see if anything sticks out to you?

annakocheshkova commented 5 years ago

@ldco2016 at this point, I would recommend to create this app from scratch, without the react-native.config and without the cycle, to eliminate both potential causes of the issue. If you do that, I would also like to look at the output of the plugin installation and android build.

ldco2016 commented 5 years ago

@annakocheshkova , I really don't think its the require cycle warning that is an issue.

In appcenterLogger.js, I commented out this code snippet:

// export function trackNavigation(from, to) {
//   Analytics.trackEvent("AppNavigation", { from, to });
// }

and in RootNavigation.js, I commented out this snippet inside an if statement:

 _screenTracking = (prevState, currentState) => {
    const currentScreen = this._getCurrentRouteName(currentState);
    const prevScreen = this._getCurrentRouteName(prevState);

    if (prevScreen !== currentScreen) {
      // appcenter.trackNavigation(prevScreen, currentScreen);
    }
  };

It allows me to Login afterwards but then I get another error. Any idea why is that trackNavigation function that it does not like?

annakocheshkova commented 5 years ago

@ldco2016 so after you comment out trackNavigation, the SDK works or still not? What is another error that appears?

annakocheshkova commented 5 years ago

I'm a bit conserned with the way you call trackEvent. It requires passing a dictionary while what you pass might be interpreted as an array. From official docs: Analytics.trackEvent('Video clicked', { Category: 'Music', FileName: 'favorite.avi' });

ldco2016 commented 5 years ago

@annakocheshkova ,

This is the error that I get when I comment out the trackNavigation function:

2019-08-15 15:19:27.119 10338-18636/com.nfibengage E/ReactNativeJS: TypeError: undefined is not an object (evaluating 'personalDetails.firstName')

    This error is located at:
        in DetailsConfirmation (created by Connect(DetailsConfirmation))
        in Connect(DetailsConfirmation) (at SceneView.js:17)
        in SceneView (at CardStack.js:455)
        in RCTView (at View.js:35)
        in View (at CardStack.js:454)
        in RCTView (at View.js:35)
        in View (at CardStack.js:453)
        in RCTView (at View.js:35)
        in View (at createAnimatedComponent.js:151)
        in AnimatedComponent (at Card.js:12)
        in Card (at PointerEventsContainer.js:39)
        in Container (at CardStack.js:498)
        in RCTView (at View.js:35)
        in View (at CardStack.js:414)
        in RCTView (at View.js:35)
        in View (at CardStack.js:413)
        in CardStack (at CardStackTransitioner.js:67)
        in RCTView (at View.js:35)
        in View (at Transitioner.js:142)
        in Transitioner (at CardStackTransitioner.js:19)
        in CardStackTransitioner (at StackNavigator.js:41)
        in Unknown (at createNavigator.js:13)
        in Navigator (at createNavigationContainer.js:226)
        in NavigationContainer (at RootNavigation.js:216)
        in RootNavigation (created by Connect(RootNavigation))
        in Connect(RootNavigation) (at App.js:247)
        in RCTView (at View.js:35)
        in View (at App.js:245)
        in Provider (at App.js:244)
        in NFIBEngage (at renderApplication.js:40)
        in RCTView (at View.js:35)
        in View (at AppContainer.js:98)
        in RCTView (at View.js:35)
        in View (at AppContainer.js:115)
        in AppContainer (at renderApplication.js:39)
annakocheshkova commented 5 years ago

Well that's not really the App Center error. What I would suggest to do is to change the trackNavigation as I advised and see if it works after.

ldco2016 commented 5 years ago

@annakocheshkova , I have refactored both appcenterLogger.js and Requester.js to no longer require each other by placing both in one file and adjusting imports and relative paths accordingly and sure enough the require cycle warning goes away, but the error of Analytics being null persists.

I also tried your suggestion, I refactored trackEvent() in two different ways:

export function trackNavigation(from, to) {
  Analytics.trackEvent("AppNavigation", { from: from, to: to });
}

and

export function trackNavigation(from, to) {
  Analytics.trackEvent("AppNavigation");
}

and the error persists. I have a copy of the application, could you give it a try on your end

annakocheshkova commented 5 years ago

Sure @ldco2016 that would be great. You can share it via e-mail which I have in my profile.

ldco2016 commented 5 years ago

@annakocheshkova , I sent you the link.

Here are my thoughts so far on what may be going on.

I think the stacktrace is misleading in saying the problem is in RootNavigation.js.

Since the error is triggered only on android and when I click on the Login button, the issue originates with onPress:

here:

/* eslint react/forbid-prop-types: "off"*/
import React from "react";
import {
  View,
  Image,
  Keyboard,
  TouchableWithoutFeedback,
  Text
} from "react-native";
import PropTypes from "prop-types";
import { connect } from "react-redux";
import { TextButton } from "react-native-material-buttons";
import { colors, v2ButtonStyles, v2Colors } from "theme";
import { Loading } from "common-components";
import { setAuthStatus } from "auth/loginActions";
import styles from "auth/styles";

const logo = require("icons/NFIB_white.png");

const propTypes = {
  loading: PropTypes.bool,
  navigation: PropTypes.object.isRequired,
  setAuthStatus: PropTypes.func.isRequired
};

export class Intro extends React.Component {
  _dismiss = () => {
    Keyboard.dismiss();
  };

  render() {
    return (
      <View style={styles.container}>
        <TouchableWithoutFeedback onPress={this._dismiss}>
          <View style={{ flex: 1 }} accessible={true}>
            <Image
              source={logo}
              style={styles.v2Logo}
              accessible={true}
              accessibilityLabel={"imgLogo"}
            />
            {this.props.loading && <Loading />}
            {!this.props.loading && (
              <View style={styles.footerWrapper}>
                <View style={styles.authButtonsWrapper} accessible={true}>
                  <TextButton
                    color={v2Colors.green}
                    title={"LOG IN"}
                    titleColor={colors.white}
                    onPress={() => this.props.navigation.navigate("Login")}
                    style={styles.authButton}
                    titleStyle={v2ButtonStyles.titleStyle}
                    accessibilityLabel={"btnLogin"}
                    accessibilityTraits={"button"}
                    accessibilityComponentType={"button"}
                  />
                  <Text style={styles.textSeparatorNewLine} />
                  <Text style={styles.textSeparatorNewLine}>
                    {" "}
                    {"First time here?"}
                  </Text>
                  <TextButton
                    color={v2Colors.green}
                    title={"REGISTER"}
                    titleColor={colors.white}
                    onPress={() => this.props.navigation.navigate("Register")}
                    style={styles.authButton}
                    titleStyle={v2ButtonStyles.titleStyle}
                    accessibilityLabel={"btnRegister"}
                    accessibilityTraits={"button"}
                    accessibilityComponentType={"button"}
                  />
                </View>
              </View>
            )}
          </View>
        </TouchableWithoutFeedback>
      </View>
    );
  }
}

Whether I click Login or whether I click Register. I get that error.

the logs Calling JS function after bridge has been destroyed: RCTDeviceEventEmitter.emit, its trying to call the analytics function after the native bridge is destroyed. What is the cause or reason for this I do not know. First time working with Appcenter.

ldco2016 commented 5 years ago

@annakocheshkova ,

I got your message and I went ahead and unlinked those appcenter packages where the error messages say to do, after doing so I get this error:

Note: Some input files use or override a deprecated API.
Note: Recompile with -Xlint:deprecation for details.
Note: /Users/danale/Projects/NFIBEngage/node_modules/react-native-swipe-view/android/src/main/java/com/wix/RNSwipeView/SwipeView.java uses or overrides a deprecated API.
Note: Recompile with -Xlint:deprecation for details.
Note: /Users/danale/Projects/NFIBEngage/node_modules/react-native-webview/android/src/main/java/com/reactnativecommunity/webview/RNCWebViewManager.java uses or overrides a deprecated API.
Note: Recompile with -Xlint:deprecation for details.
Note: /Users/danale/Projects/NFIBEngage/node_modules/react-native-webview/android/src/main/java/com/reactnativecommunity/webview/RNCWebViewManager.java uses unchecked or unsafe operations.
Note: Recompile with -Xlint:unchecked for details.
/Users/danale/Projects/NFIBEngage/android/app/src/main/java/com/nfib/engage/MainApplication.java:37: error: cannot find symbol
      packages.add(new AppCenterReactNativeCrashesPackage(MainApplication.this, getResources().getString(R.string.appCenterCrashes_whenToSendCrashes)));
                       ^
  symbol: class AppCenterReactNativeCrashesPackage
/Users/danale/Projects/NFIBEngage/android/app/src/main/java/com/nfib/engage/MainApplication.java:38: error: cannot find symbol
      packages.add(new AppCenterReactNativeAnalyticsPackage(MainApplication.this, getResources().getString(R.string.appCenterAnalytics_whenToEnableAnalytics)));
                       ^
  symbol: class AppCenterReactNativeAnalyticsPackage
/Users/danale/Projects/NFIBEngage/android/app/src/main/java/com/nfib/engage/MainApplication.java:39: error: cannot find symbol
      packages.add(new AppCenterReactNativePackage(MainApplication.this));
                       ^
  symbol: class AppCenterReactNativePackage
3 errors

This error is in reference to my MainApplication.java file:

package com.nfib.engage;

import android.app.Application;
import android.util.Log;

import com.facebook.react.PackageList;
import com.facebook.hermes.reactexecutor.HermesExecutorFactory;
import com.facebook.react.bridge.JavaScriptExecutorFactory;
import com.facebook.react.ReactApplication;
import com.learnium.RNDeviceInfo.RNDeviceInfo;
import com.wix.RNSwipeView.SwipeViewPackage;
import com.geektime.rnonesignalandroid.ReactNativeOneSignalPackage;
import io.sentry.RNSentryPackage;
import com.reactnativecommunity.webview.RNCWebViewPackage;
import com.facebook.react.ReactNativeHost;
import com.facebook.react.ReactPackage;
import com.facebook.soloader.SoLoader;
import com.github.wumke.RNImmediatePhoneCall.RNImmediatePhoneCallPackage;
import org.devio.rn.splashscreen.SplashScreenReactPackage;

import java.util.List;

public class MainApplication extends Application implements ReactApplication {

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

    @Override
    protected List<ReactPackage> getPackages() {
      @SuppressWarnings("UnnecessaryLocalVariable")
      List<ReactPackage> packages = new PackageList(this).getPackages();
      // Packages that cannot be autolinked yet can be added manually here, for example:
      // packages.add(new MyReactNativePackage());
      packages.add(new AppCenterReactNativeCrashesPackage(MainApplication.this, getResources().getString(R.string.appCenterCrashes_whenToSendCrashes)));
      packages.add(new AppCenterReactNativeAnalyticsPackage(MainApplication.this, getResources().getString(R.string.appCenterAnalytics_whenToEnableAnalytics)));
      packages.add(new AppCenterReactNativePackage(MainApplication.this));
      packages.add(new ReactNativeOneSignalPackage());
      packages.add(new RNSentryPackage());
      packages.add(new RNDeviceInfo());
      new SplashScreenReactPackage();
      packages.add(new RNImmediatePhoneCallPackage());
      packages.add(new SwipeViewPackage());
      return packages;
    }

Is the above not configured correctly for RN version 60.4?

annakocheshkova commented 5 years ago

@ldco2016 I suggest you follow the upgrade steps as officially advised by React-Native.

ldco2016 commented 5 years ago

@annakocheshkova , my application is upgraded and I followed meticulous steps to do over a month ago. My question is in regards to what is the proper configuration for MainApplication.java regarding Appcenter.

annakocheshkova commented 5 years ago

@ldco2016 the packages configuration moved to another place since RN 0.60. So after you unlinked them, I suggest you remove those packages and re-install them, so that they are added by autolinking where they belong. The code that produces the above error can be deleted then.

ldco2016 commented 5 years ago

I unlinked then uninstalled and removed the configuration from MainApplication.java and I am not only did I get the same error when trying to log into my android app, but now this error has come back:

error React Native CLI uses autolinking for native dependencies, but the following modules are linked manually:
  - appcenter (to unlink run: "react-native unlink appcenter")
  - appcenter-analytics (to unlink run: "react-native unlink appcenter-analytics")
  - appcenter-crashes (to unlink run: "react-native unlink appcenter-crashes")

I promise you I have not manually linked anything. All I did was add this to build.gradle:

dependencies {
    implementation project(':react-native-device-info')
    implementation project(':react-native-onesignal')
    implementation project(':react-native-webview')
    implementation project(':react-native-immediate-phone-call')
    implementation project(':RNSwipeView')
    implementation project(':react-native-splash-screen')
    implementation project(':appcenter-crashes')
    implementation project(':appcenter-analytics')
    implementation project(':appcenter')
    implementation fileTree(dir: "libs", include: ["*.jar"])
    implementation "com.facebook.react:react-native:+"  // From node_modules

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

and this to settings.gradle:

rootProject.name = 'NFIBEngage'

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-onesignal'
project(':react-native-onesignal').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-onesignal/android')
include ':react-native-sentry'
project(':react-native-sentry').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-sentry/android')
include ':react-native-immediate-phone-call'
project(':react-native-immediate-phone-call').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-immediate-phone-call/android')
include ':react-native-webview'
project(':react-native-webview').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-webview/android')
apply from: file("../node_modules/@react-native-community/cli-platform-android/native_modules.gradle"); applyNativeModulesSettingsGradle(settings)
include ':appcenter-crashes'
project(':appcenter-crashes').projectDir = new File(rootProject.projectDir, '../node_modules/appcenter-crashes/android')
include ':appcenter-analytics'
project(':appcenter-analytics').projectDir = new File(rootProject.projectDir, '../node_modules/appcenter-analytics/android')
include ':appcenter'
project(':appcenter').projectDir = new File(rootProject.projectDir, '../node_modules/appcenter/android')
include ':RNSwipeView'
project(':RNSwipeView').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-swipe-view/android')
include ':react-native-splash-screen'
project(':react-native-splash-screen').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-splash-screen/android')

include ':app'
annakocheshkova commented 5 years ago

That's one of the stages autolinking does for you. You need to remove changes in build.gradle as well.

ldco2016 commented 5 years ago

@annakocheshkova , interesting because when I went into build.gradle there was nothing for appcenter there, that's why I added it manually, but even before I did that, I continued to get the same error about null is not an object after I removed the configuration from MainApplication.java.

annakocheshkova commented 5 years ago

Well first of all react-native should add dependencies to settings.gradle, and if I'm not mistaken at build time. So if you are saying that you re-installed modules and nothing appeared in gradle files, you shouldn't have added it manually. The only thing you need to do manually for android is this

annakocheshkova commented 5 years ago

I suggest the following workflow (I know you already have done some of it, just summarizing here):

ldco2016 commented 5 years ago

@annakocheshkova ,

I just followed your workflow and unfortunately, I continue to get the same error message.

I have no code in gradle files, no code in MainApplication.java, no code in settings.gradle.

The only one I added is:

<resources>
  <string name="appCenterCrashes_whenToSendCrashes" moduleConfig="true" translatable="false">ASK_JAVASCRIPT</string>
  <string name="appCenterAnalytics_whenToEnableAnalytics" moduleConfig="true" translatable="false">ALWAYS_SEND</string>
</resources>

In strings.xml because that is the only way I was able to get a successful build, but when I try to login, I get the same null is not an object error for AppCenterReactNativeAnalytics.trackevent.

No error about it being manually linked either.

annakocheshkova commented 5 years ago

@ldco2016 so I deleted all the manually linked modules from your app (not only App Center) and re-installed them, not only did I get a message about them being manually linked but the modules were not autolinked either. So far it looks like still related to migration problem: the modules are supposed to be autolinked properly, but becasue they were manually linked, it might be causing problems. The fact that I don't see any logs from App Center only proves that. I think what you need to do is open a ticket in react-native repo to help you migrate in this situation. They know the details better than I do.

ldco2016 commented 5 years ago

@annakocheshkova ,

So apparently it is a linking issue based on this console log:

2019-09-06 11:00:07.421 4649-23060/com.nfibengage I/ReactNativeJS: 'trackNavigation', { bindingType: 'com.microsoft.appcenter.analytics.Analytics',
      trackEvent: [Function: trackEvent],
      isEnabled: [Function: isEnabled],
      setEnabled: [Function: setEnabled],
      getTransmissionTarget: [Function: getTransmissionTarget],
      PropertyConfigurator: [Function: _class],
      TransmissionTarget: [Function: _class2] }
2019-09-06 11:00:07.422 4649-23060/com.nfibengage E/ReactNativeJS: null is not an object (evaluating 'AppCenterReactNativeAnalytics.trackEvent')
2019-09-06 11:00:07.508 4649-23060/com.nfibengage E/ReactNativeJS: Module AppRegistry is not a registered callable module (calling runApplication)
2019-09-06 11:00:07.550 4649-4680/com.nfibengage D/EGL_emulation: eglMakeCurrent: 0xe1abf020: ver 3 0 (tinfo 0xdddc08b0)

when I added this:

export function trackNavigation(from, to) {
  console.log("trackNavigation", Analytics);
  Analytics.trackEvent("AppNavigation", { from, to });
}

trackNavigation("from", "to");

I really need assistance here because at this point I do not have appcenter manually linked anywhere in my project, all I do is npm install all the appcenter packages.

russelarms commented 5 years ago

Hi @ldco2016, could you please share the contents of appName/android/app/build/generated/rncli/src/main/java/com/facebook/react/PackageList.java ? It is a generated file, that is created after running react-native run-android.

Also, please check out this sample app: https://github.com/russelarms/rn60sample (don't forget to change APP_SECRET). Could you find any differences from your setup? Does it work for you?

ldco2016 commented 5 years ago

@russelarms , the following are the contents of appName/android/app/build/generated/rncli/src/main/java/com/facebook/react/PackageList.java:

package com.facebook.react;

import android.app.Application;
import android.content.Context;
import android.content.res.Resources;

import com.facebook.react.ReactPackage;
import com.facebook.react.shell.MainReactPackage;
import java.util.Arrays;
import java.util.ArrayList;

import com.nfibengage.BuildConfig;
import com.nfibengage.R;

// @react-native-community/async-storage
import com.reactnativecommunity.asyncstorage.AsyncStoragePackage;
// appcenter
import com.microsoft.appcenter.reactnative.appcenter.AppCenterReactNativePackage;
// appcenter-analytics
import com.microsoft.appcenter.reactnative.analytics.AppCenterReactNativeAnalyticsPackage;
// appcenter-crashes
import com.microsoft.appcenter.reactnative.crashes.AppCenterReactNativeCrashesPackage;
// react-native-device-info
import com.learnium.RNDeviceInfo.RNDeviceInfo;
// react-native-gesture-handler
import com.swmansion.gesturehandler.react.RNGestureHandlerPackage;
// react-native-immediate-phone-call
import com.github.wumke.RNImmediatePhoneCall.RNImmediatePhoneCallPackage;
// react-native-reanimated
import com.swmansion.reanimated.ReanimatedPackage;
// react-native-sentry
import io.sentry.RNSentryPackage;
// react-native-splash-screen
import org.devio.rn.splashscreen.SplashScreenReactPackage;
// react-native-svg
import com.horcrux.svg.SvgPackage;
// react-native-swipe-view
import com.wix.RNSwipeView.SwipeViewPackage;
// react-native-vector-icons
import com.oblador.vectoricons.VectorIconsPackage;
// react-native-webview
import com.reactnativecommunity.webview.RNCWebViewPackage;

public class PackageList {
  private Application application;
  private ReactNativeHost reactNativeHost;
  public PackageList(ReactNativeHost reactNativeHost) {
    this.reactNativeHost = reactNativeHost;
  }

  public PackageList(Application application) {
    this.reactNativeHost = null;
    this.application = application;
  }

  private ReactNativeHost getReactNativeHost() {
    return this.reactNativeHost;
  }

  private Resources getResources() {
    return this.getApplication().getResources();
  }

  private Application getApplication() {
    if (this.reactNativeHost == null) return this.application;
    return this.reactNativeHost.getApplication();
  }

  private Context getApplicationContext() {
    return this.getApplication().getApplicationContext();
  }

  public ArrayList<ReactPackage> getPackages() {
    return new ArrayList<>(Arrays.<ReactPackage>asList(
      new MainReactPackage(),
      new AsyncStoragePackage(),
      new AppCenterReactNativePackage(getApplication()),
      new AppCenterReactNativeAnalyticsPackage(getApplication(), getResources().getString(R.string.appCenterAnalytics_whenToEnableAnalytics)),
      new AppCenterReactNativeCrashesPackage(getApplication(), getResources().getString(R.string.appCenterCrashes_whenToSendCrashes)),
      new RNDeviceInfo(),
      new RNGestureHandlerPackage(),
      new RNImmediatePhoneCallPackage(),
      new ReanimatedPackage(),
      new RNSentryPackage(),
      new SplashScreenReactPackage(),
      new SvgPackage(),
      new SwipeViewPackage(),
      new VectorIconsPackage(),
      new RNCWebViewPackage()
    ));
  }
}

Also, this is what my android/settings.gradle looks like:

rootProject.name = 'NFIBEngage'

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-onesignal'
project(':react-native-onesignal').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-onesignal/android')
include ':react-native-sentry'
project(':react-native-sentry').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-sentry/android')
include ':react-native-immediate-phone-call'
project(':react-native-immediate-phone-call').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-immediate-phone-call/android')
include ':RNSwipeView'
project(':RNSwipeView').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-swipe-view/android')
apply from: file("../node_modules/@react-native-community/cli-platform-android/native_modules.gradle"); applyNativeModulesSettingsGradle(settings)
include ':RNSwipeView'
project(':RNSwipeView').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-swipe-view/android')

include ':app'
russelarms commented 5 years ago

The generated file (PackageList.java) looks OK, could you send us a reproducible sample once again?

ldco2016 commented 5 years ago

@russelarms , you can use this one: https://www.dropbox.com/s/9ic96cz9qupi97j/ipa_release_2.0.zip?dl=0

When you do an npm install, you will also have to go to node_modules:

node_modules/react-native-immediate-phone-call/android/build.gradle AND node_modules/react-native-swipe-view/android/build.gradle

change compileSdkVersion to 28

change targetSdkVersion to 27

russelarms commented 4 years ago

Hi again! I've sent you an email with your project, please check it out. I've made some changes in order to build it, but nothing related to AppCenter. After I've managed to build it, I verified that Analytics works just fine.

What I did in order to build the project:

ldco2016 commented 4 years ago

@russelarms ,

When you say you removed all build and iml files (I was not aware of these iml files) and restarted android studio, did you do a rm -rf android/build? and then restart android studio?

russelarms commented 4 years ago

@ldco2016 yes, I removed that one too. It contains build artifacts that will be generated once you try to build the app.

ldco2016 commented 4 years ago

@russelarms , I noticed you still have this:

// _screenTracking = (prevState, currentState) => {
  //   const currentScreen = this._getCurrentRouteName(currentState);
  //   const prevScreen = this._getCurrentRouteName(prevState);
  //   // comment out if removing appcenter
  //   if (prevScreen !== currentScreen) {
  //     appcenter.trackNavigation(prevScreen, currentScreen);
  //   }
  // };

commented out.

If you uncomment that, plus uncomment the following:

render() {
    if (
      this.props.user &&
      this.props.user.authStatus === AUTH_STATUS.LOGGED_IN
    ) {
      return (
        <DrawerStack
          ref={nav => {
            this.navigator = nav;
          }}
          // onNavigationStateChange={this._screenTracking}
        />
      );
    }
    return (
      <AuthStack
        authStatus={this.props.user.authStatus}
        // onNavigationStateChange={this._screenTracking}
        ref={nav => {
          this.navigator = nav;
        }}
      />
    );

The app crashes with that same message. Also, I failed to mention a good test of whether it is working is to uncomment this:

// add this, restart the app, run it and see what console says
export function trackNavigation(from, to) {
  console.log("trackNavigation", Analytics);
  Analytics.trackEvent("AppNavigation", { from, to });
}

// trackNavigation("from", "to");

When you attempt to login, it will crash with the same error, before even logging in or trying anything else. Why? My theory is that the application can see the JS lib for Appcenter, but it cannot see the native lib for Appcenter.

I say that based on this output from console log of "trackNavigation", Analytics.

russelarms commented 4 years ago

I uncommented screenTracking calls and didn't get any errors in the debugger console (I used Google Chrome, not Reactotron). All the events (including "AppNavigation" "Intro > Login" and "Login < Intro") successfully appeared on the portal.

I believe there's a problem in your environment setup. Could you try to clean all the cache or build it on another machine?

ldco2016 commented 4 years ago

@russelarms , I just tried running the version you sent me via email and at first I did not get the error, but then I did. This is a tricky bug and I do not think its my environment setup since I finally got a chance to run your version and it did not work. Could it be my machine? I am not sure, but that version you gave me has the same bug.

Could it possibly be a scoping issue?

_screenTracking = (prevState, currentState) => {
    const currentScreen = this._getCurrentRouteName(currentState);
    const prevScreen = this._getCurrentRouteName(prevState);
    // comment out if removing appcenter
    if (prevScreen !== currentScreen) {
      // appcenter.trackNavigation(prevScreen, currentScreen);
    }
  };

The above appcenter.trackNavigation() is not accessible to this here:

return (
        <DrawerStack
          ref={nav => {
            this.navigator = nav;
          }}
          // onNavigationStateChange={this._screenTracking}
        />
      );

You got to play in my environment, so I am unclear as to how it can be my environment when you had a copy of it. Can you be more specific what about my environment setup would be different to yours?

I am on a MacBook Pro mid-2015, I am using Android Studio 3.5, the android part you already tinkered with. Did you see anything out of place about the environment there? Its only a problem in android so thats all that matters, not having this problem on the iOS side, I imagine this is why you removed ios/ completely.

I have been told repeatedly by others its a linking issue, but they have no idea how. I have been told its that my project cannot access appcenters native library. How can this happen? They cannot tell me. I am directed to study my project more. Please tell me, I spend 40 hours a week on this project for over 4 months, what could I have possibly missed inside the environment? The only thing different I saw was these iml files and the changes you made, but again, your copy has the same error as mine when I run it.

russelarms commented 4 years ago

and at first I did not get the error, but then I did.

So when you first build and run the app everything worked as expected? What happened next?

Could it possibly be a scoping issue?

If it works in one part of the code, it should work in the other.

The above appcenter.trackNavigation() is not accessible to this here:

Just checked once again and it works fine for me. Got all the events that were called inside

return (
        <DrawerStack
          ref={nav => {
            this.navigator = nav;
          }}
          // onNavigationStateChange={this._screenTracking}
        />
      );

@ldco2016 I've sent you a full archive, check your email. The difference in the environment could be way more subtle than just an os and android studio versions. Have you tried to debug it inside Google Chrome debugger console, not Reactotron? I included node_modules and build files in the archive this time, I hope it will help.

Btw, here's my binaries versions:

  Binaries:
    Node: 10.16.0 - /usr/local/bin/node
    Yarn: 1.13.0 - ~/.yarn/bin/yarn
    npm: 6.9.0 - /usr/local/bin/npm
    Watchman: 4.7.0 - /usr/local/bin/watchman
ldco2016 commented 4 years ago

I verified that your version does work on my machine, so I copied your android/ folder and removed mine and replaced it with yours.

I then got the following error:

Error: spawnSync ./gradlew EACCES

which I resolved by running this command:

chmod 755 android/gradlew

Then the project built successfully as it always does, but as soon as I clicked the Login button, I got the same TypeError: null is not an object (evaluating 'AppCenterReactNativeAnalytics.trackEvent'), but this time I also got this in Metro Bundler:

info Opening /Users/danale/Projects/NFIBEngage/node_modules/appcenter-analytics/Analytics.js with atom
info Opening /Users/danale/Projects/NFIBEngage/node_modules/appcenter-analytics/Analytics.js with atom
info Opening /Users/danale/Projects/NFIBEngage/node_modules/appcenter-analytics/Analytics.js with atom

and my Atom editor took me to Analytics.js file and presented me with this particular section:

// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.

const ReactNative = require('react-native');

const { AppCenterReactNativeAnalytics } = ReactNative.NativeModules;

const Analytics = {
    bindingType: ReactNative.Platform.select({
        ios: 'MSAnalytics',
        android: 'com.microsoft.appcenter.analytics.Analytics',
    }),

    // async - returns a Promise
    trackEvent(eventName, properties) {
        return AppCenterReactNativeAnalytics.trackEvent(eventName, sanitizeProperties(properties));
    },

    // async - returns a Promise
    isEnabled() {
        return AppCenterReactNativeAnalytics.isEnabled();
    },

    // async - returns a Promise
    setEnabled(enabled) {
        return AppCenterReactNativeAnalytics.setEnabled(enabled);
    },

I am still unclear what is going on, but wanted to share my process, perhaps there is something I am missing.

I also copied and pasted your src/ folder and I am still getting that error.

The error is complaining about this line -> Analytics.trackEvent("AppNavigation", { from, to }); and this line -> appcenter.trackNavigation(prevScreen, currentScreen); on my project.

What is different? This is frustrating. Then when I try to launch your version again, it stays stuck on it cannot access the development server.

russelarms commented 4 years ago

I verified that your version does work on my machine, so I copied your android/ folder and removed mine and replaced it with yours.

As I understand, you were able to build the project from my archive and verify that it works and there's no TypeError: null is not an object bug, but when you tried to move the files from my archive you encountered the same error, is it correct?

Please check out your email.