dd-sdk-reactnative: Android issue: null is not an object (evaluating 'this.nativeRum.startView')

Describe what happened Include any error message or stack trace if available.

Everything works on iOS, and data comes through to my DataDog dashboard. When attempting to run on Android emulators I receive this error after the app successfully installs and opens: null is not an object (evaluating 'this.nativeRum.startView'). It points to the file foundation.tsx and line 50.

I also tried clearing all caches multiple times.

Here is the stack trace: Screen Shot 2022-01-04 at 3 01 55 AM

Steps to reproduce the issue:

  • tested with a Pixel 4 emulator with API 28 (Android 9.0), and a Galaxy S20 Ultra emulator with API 30 (Android 11.0)

Describe what you expected:

Additional context - Version of the SDK - @datadog/mobile-react-native@1.0.0-rc - @datadog/mobile-react-navigation@1.0.0-rc4 - A copy of your package.json file: - Note: I have ejected from expo

{
  "name": "",
  "scripts": {},
  "dependencies": {
    "@datadog/mobile-react-native": "^1.0.0-rc4",
    "@datadog/mobile-react-navigation": "^1.0.0-rc4",
    "@expo/vector-icons": "^12.0.0",
    "@ptomasroos/react-native-multi-slider": "^2.2.2",
    "@react-native-async-storage/async-storage": "^1.13.2",
    "@react-native-community/cli-platform-ios": "^4.13.0",
    "@react-native-community/cookies": "^5.0.1",
    "@react-native-community/masked-view": "^0.1.6",
    "@react-navigation/bottom-tabs": "^6.0.9",
    "@react-navigation/native": "^6.0.6",
    "@react-navigation/stack": "^6.0.11",
    "@unimodules/core": "~6.0.0",
    "@unimodules/react-native-adapter": "~5.7.0",
    "bcrypt": "^3.0.6",
    "blinkid-react-native": "^5.8.1",
    "expo": "^40.0.0",
    "expo-asset": "~8.2.1",
    "expo-constants": "~9.3.3",
    "expo-facebook": "~9.1.0",
    "expo-file-system": "~9.3.0",
    "expo-font": "~8.4.0",
    "expo-linear-gradient": "~8.4.0",
    "install": "^0.13.0",
    "lodash": "^4.17.15",
    "npm": "^8.3.0",
    "payment-icons": "^1.2.1",
    "react": "16.13.1",
    "react-dom": "16.13.1",
    "react-native": "0.63.4",
    "react-native-code-push": "^6.2.1",
    "react-native-datepicker": "^1.7.2",
    "react-native-dotenv": "^2.5.1",
    "react-native-elements": "^1.2.7",
    "react-native-firebase": "^5.6.0",
    "react-native-gesture-handler": "~1.8.0",
    "react-native-google-places-autocomplete": "^2.1.2",
    "react-native-indicators": "^0.17.0",
    "react-native-keyboard-aware-scroll-view": "^0.9.5",
    "react-native-onesignal": "^4.0.1",
    "react-native-picker-select": "^6.5.0",
    "react-native-reanimated": "^1.7.0",
    "react-native-rn-apple-pay-button": "github:brascene/rn-apple-pay-button",
    "react-native-safe-area-context": "^3.2.0",
    "react-native-screens": "^3.10.1",
    "react-native-sectioned-multi-select": "^0.8.1",
    "react-native-unimodules": "~0.12.0",
    "react-native-vector-icons": "^6.6.0",
    "react-native-video": "^5.0.0",
    "react-native-web": "~0.13.12",
    "react-redux": "^7.1.0",
    "redux": "^4.0.4",
    "redux-thunk": "^2.3.0",
    "tipsi-stripe": "^9.1.1"
  },
  "devDependencies": {
    "@babel/core": "~7.9.0",
    "@babel/runtime": "^7.8.4",
    "@types/react": "~16.9.35",
    "@types/react-native": "~0.63.2",
    "babel-jest": "~24.9.0",
    "babel-preset-expo": "8.3.0",
    "jest": "~24.9.0",
    "jetifier": "~1.6.4",
    "metro-react-native-babel-preset": "^0.59.0",
    "react-test-renderer": "~16.13.1",
    "typescript": "^4.5.4"
  },
  "private": true
}

Any help is appreciated!

About this issue

  • Original URL
  • State: open
  • Created 2 years ago
  • Reactions: 1
  • Comments: 24 (9 by maintainers)

Most upvoted comments

I face the same problem: error [TypeError: null is not an object (evaluating '_$$_REQUIRE(_dependencyMap[5], "./foundation").DdSdk.initialize')]

The initialization is exactly the same as the sample on dd console:

import {
  DdSdkReactNative,
  DdSdkReactNativeConfiguration,
} from '@datadog/mobile-react-native';

const config = new DdSdkReactNativeConfiguration(
  'something',
  'DEBUG',
  'something',
  true, // track User interactions (e.g.: Tap on buttons. You can use 'accessibilityLabel' element property to give tap action the name, otherwise element type will be reported)
  true, // track XHR Resources
  true, // track Errors
);
// Optional: Select your Datadog website (one of "US", "EU" or "GOV")
config.site = 'US';
// Optional: enable or disable native crash reports
config.nativeCrashReportEnabled = true;
// Optional: sample RUM sessions (here, 80% of session will be sent to Datadog. Default = 100%)
config.sampleRate = 80;

DdSdkReactNative.initialize(config)
  .then(() => {
    console.log('works');
  })
  .catch(err => {
    console.log('error', err);
  });

Hi @chiaraturbati, thanks for reaching out!

This is unfortunately a long standing issue that we have a hard time reproducing. I found this issue on the React Native repo suggesting to turn on the Debug mode for your app (which should open a Google Chrome tab) as a fix.

Could you try it and see if it works?

If this does not fix the issue, you can run npx rn-game-over -j -a to clear all the javascript and android caches and see if it works.

This is still an issue for me. The initialization fails because DdSdkReactNative is undefined, only happens on Android. EDIT: Its actually in DdRumReactNavigationTracking.tsx, when running DdSdk.initialize. DdSdk is undefined.

After adding mannuelly below import in MainApplication.java this issue got resolved import com.datadog.reactnative.DdSdkReactNativePackage;

protected List<ReactPackage> getPackages() {
                    return Arrays.<ReactPackage>asList(
                    ....
                    new DdSdkReactNativePackage()
                    .....
                    )
                    }

example/android/app/src/main/java/com/example/ddsdkreactnative/MainApplication.java

Now working fine for me

Till facing this below issue in android [TypeError: null is not an object (evaluating ‘_$$_REQUIRE(_dependencyMap[7], “./foundation”).DdSdk.initialize’)]

"@datadog/mobile-react-native": "^1.0.0-rc5",
"@datadog/mobile-react-navigation": "^1.0.0-rc5",

I am sorry @0xnm We had to disable datadog on our next android build.

I had tried to comment you mentioned. No success.

Our dependencies are the following:

{
 "dependencies": {
    "@babel/polyfill": "^7.2.5",
    "@babel/preset-flow": "^7.13.13",
    "@bugsnag/react-native": "^7.3.0",
    "@datadog/mobile-react-native": "^1.0.0-rc4",
    "@hookform/resolvers": "^2.8.8",
    "@react-native-async-storage/async-storage": "^1.15.5",
    "@react-native-community/art": "^1.2.0",
    "@react-native-community/geolocation": "^2.0.2",
    "@react-native-community/masked-view": "^0.1.11",
    "@react-native-firebase/analytics": "^11.5.0",
    "@react-native-firebase/app": "^11.5.0",
    "@react-native-firebase/messaging": "^11.5.0",
    "@react-native-picker/picker": "^1.16.8",
    "buffer": "5.2.1",
    "color": "^3.1.0",
    "compare-versions": "^3.6.0",
    "fast-memoize": "^2.5.1",
    "formik": "^1.3.1",
    "hermes-engine": "^0.7.2",
    "jwt-decode": "^2.2.0",
    "libphonenumber-js": "^1.7.8",
    "lodash": "^4.17.21",
    "moment": "^2.24.0",
    "moment-timezone": "^0.5.23",
    "node-polyglot": "^2.3.0",
    "phoenix-socket": "^1.2.3",
    "promise-timeout": "^1.3.0",
    "react": "17.0.1",
    "react-native": "0.64.1",
    "react-native-adjust": "^4.29.5",
    "react-native-appboy-sdk": "^1.28.0",
    "react-native-barcode-builder": "^2.0.0",
    "react-native-device-info": "^8.1.3",
    "react-native-exception-handler": "^2.10.10",
    "react-native-fs": "^2.18.0",
    "react-native-gesture-handler": "^1.10.3",
    "react-native-get-random-values": "^1.7.0",
    "react-native-haptic-feedback": "^1.11.0",
    "react-native-maps": "^0.28.0",
    "react-native-permissions": "^3.0.3",
    "react-native-rate": "^1.2.6",
    "react-native-restart": "^0.0.22",
    "react-native-safe-area-context": "^3.2.0",
    "react-native-screens": "^2.15.2",
    "react-native-splash-screen": "^3.2.0",
    "react-native-svg": "^12.1.1",
    "react-native-tracking-transparency": "^0.1.1",
    "react-native-video": "^5.1.1",
    "react-navigation": "^4.4.4",
    "react-navigation-stack": "^2.10.4",
    "react-redux": "^7.2.4",
    "redux": "^4.1.0",
    "redux-saga": "^1.1.3",
    "reselect": "^4.0.0",
    "route-parser": "^0.0.5",
    "tipsi-stripe": "^9.0.0",
    "url-search-params-polyfill": "^5.0.0",
    "uuid": "^8.3.2",
    "whatwg-url": "7.0.0",
    "yup": "^0.32.9"
  }
}

In my case

 ERROR  [TypeError: null is not an object (evaluating '_$$_REQUIRE(_dependencyMap[5], "./foundation").DdSdk.initialize')]