DataDog / dd-sdk-reactnative

Datadog SDK for ReactNative
Apache License 2.0
122 stars 42 forks source link

Android only crash: DdRumContentProvider.onCreate(): [0x74] register v3 has type Reference: android.app.ActivityManager$RunningAppProcessInfo #729

Open compwron opened 1 month ago

compwron commented 1 month ago

Stack trace

As recorded by attached Flipper (0.269.0)

FATAL EXCEPTION: main

java.lang.VerifyError: 
Verifier rejected class com.datadog.android.rum.DdRumContentProvider: 
boolean com.datadog.android.rum.DdRumContentProvider.onCreate() failed to verify: 
boolean com.datadog.android.rum.DdRumContentProvider.onCreate(): 
[0x74] register v3 has type Reference: android.app.ActivityManager$RunningAppProcessInfo 
but expected Reference: android.content.ContentProvider 
(declaration of 'com.datadog.android.rum.DdRumContentProvider' appears in /data/app/~~Cu8gDu9g3W48nDVfQxEfeA==/com.mycompany.myapp-b_6zC6QWataL1TztyaPmAQ==/base.apk)

Built by:

Android Studio Ladybug | 2024.2.1
Build #AI-242.21829.142.2421.12409432, built on September 24, 2024
Runtime version: 21.0.3+-79915917-b509.11 aarch64
VM: OpenJDK 64-Bit Server VM by JetBrains s.r.o.
Toolkit: sun.lwawt.macosx.LWCToolkit
macOS 14.6.1
GC: G1 Young Generation, G1 Concurrent GC, G1 Old Generation
Memory: 4096M
Cores: 10
Metal Rendering is ON
Registry:
  debugger.new.tool.window.layout=true
  ide.experimental.ui=true
  i18n.locale=
Non-Bundled Plugins:
  idea.plugin.protoeditor (242.21829.3)

Reproduction steps

I followed https://docs.datadoghq.com/real_user_monitoring/mobile_and_tv_monitoring/setup/reactnative/#setup

import {
    DatadogProvider,
    DatadogProviderConfiguration
} from '@datadog/mobile-react-native';

const config = new DatadogProviderConfiguration(
    Config.DATADOG_CLIENT_TOKEN || "",
    Config.DATADOG_ENVIRONMENT_NAME || "",
    Config.DATADOG_RUM_APPLICATION_ID || "",
    true, // track user interactions (such as a tap on buttons).
    true, // track XHR resources
    true // track errors
);
config.site = 'US1';
// Optional: Enable or disable native crash reports
config.nativeCrashReportEnabled = true;
// Optional: Sample RUM sessions (in this example, 80% of session are sent to Datadog. Default is 100%).
config.sessionSamplingRate = 80;
// Optional: Sample tracing integrations for network calls between your app and your backend (in this example, 80% of calls to your instrumented backend are linked from the RUM view to the APM view. Default is 20%)
// You need to specify the hosts of your backends to enable tracing with these backends
config.resourceTracingSamplingRate = 80;
config.firstPartyHosts = ['example.com']; // matches 'example.com' and subdomains like 'api.example.com'
// Optional: set the reported service name (by default, it uses the package name or bundleIdentifier of your Android or iOS app respectively)
config.serviceName = 'com.example.reactnative';
// Optional: let the SDK print internal logs above or equal to the provided level. Default is undefined (meaning no logs)
config.verbosity = SdkVerbosity.WARN;

//Wrap the content of your App component in a DatadogProvider component, passing it your configuration:

export default function App() {
    return (
        <DatadogProvider configuration={config}>
            <Navigation />
        </DatadogProvider>
    );
}

Volume

100

Affected SDK versions

2.4.3

Latest working SDK version

none, and also there's a typo in this question "where the crash did manifest itself?"

Does the crash manifest in the latest SDK version?

Yes

React Native Version

0.71.19

Package.json Contents

{
  "name": "redacted",
  "version": "1.1.1",
  "private": true,
  "scripts": {
    "android": "react-native run-android",
    "ios": "react-native run-ios",
    "lint": "eslint . && npx prettier --check .",
    "lint:fix": "eslint . --fix && npx prettier --write .",
    "start": "react-native start",
    "test": "npm run test:type && npm run test:jest",
    "test:type": "npm run build",
    "test:lint": "npm run lint",
    "test:jest": "jest",
    "test:watch": "jest --watch",
    "build": "tsc",
    "postinstall": "npx pod-install --no-repo-update --verbose"
  },
  "dependencies": {
    "@datadog/mobile-react-native": "^2.4.3",
    "@emotion/eslint-plugin": "^11.11.0",
    "@emotion/native": "^11.11.0",
    "@emotion/react": "^11.13.3",
    "@fortawesome/fontawesome-svg-core": "^6.5.2",
    "@fortawesome/free-regular-svg-icons": "^6.4.0",
    "@fortawesome/free-solid-svg-icons": "^6.4.0",
    "@fortawesome/react-native-fontawesome": "^0.3.0",

    "@react-native-firebase/app": "^19.2.2",
    "@react-native-firebase/messaging": "^17.5.0",
    "@react-native/gradle-plugin": "^0.75.2",
    "@react-native/metro-config": "^0.74.81",
    "@react-navigation/native": "^6.1.18",
    "@react-navigation/stack": "^6.3.17",
    "@sentry/react-native": "^5.33.1",
    "@types/humps": "^2.0.2",
    "@types/lodash.debounce": "^4.0.7",
    "@types/pluralize": "^0.0.33",
    "@types/react-native-background-timer": "^2.0.0",
    "add": "^2.0.6",
    "axios": "^1.7.4",
    "babel-plugin-module-resolver": "^5.0.0",
    "base64url": "^3.0.1",
    "buffer": "^6.0.3",
    "date-fns": "^2.30.0",
    "dot-prop": "^9.0.0",
    "eslint-plugin-module-resolver": "^1.5.0",
    "fetch-mock-jest": "^1.5.1",
    "humps": "^2.0.1",
    "jest-environment-jsdom": "^29.5.0",
    "jest-mock-axios": "^4.7.2",
    "lodash": "^4.17.21",
    "pluralize": "^8.0.0",
    "react": "18.2.0",
    "react-native": "0.71.19",
    "react-native-aes-crypto": "^3.0.3",
    "react-native-background-timer": "^2.4.1",
    "react-native-camera": "^4.2.1",
    "react-native-config": "^1.5.0",
    "react-native-controlled-mentions": "^2.2.5",
    "react-native-device-info": "^10.13.2",
    "react-native-gesture-handler": "^1.10.3",
    "react-native-inappbrowser-reborn": "^3.7.0",
    "react-native-keychain": "^8.2.0",
    "react-native-linear-gradient": "^2.8.3",
    "react-native-pager-view": "^6.3.1",
    "react-native-paper": "^5.12.3",
    "react-native-paper-select": "^1.1.1",
    "react-native-paper-tabs": "^0.7.0",
    "react-native-permissions": "^4.1.5",
    "react-native-reanimated": "^3.6.1",
    "react-native-safe-area-context": "^4.11.0",
    "react-native-screens": "^3.31.1",
    "react-native-select-dropdown": "^4.0.1",
    "react-native-splash-screen": "^3.3.0",
    "react-native-svg": "^15.5.0",
    "react-native-url-polyfill": "^1.3.0",
    "react-native-user-inactivity": "^1.2.0",
    "react-native-vector-icons": "^10.1.0",
    "react-native-webview": "^11.16.0",
    "trim-newlines": "^5.0.0",
    "ts-jest": "^29.1.0"
  },
  "devDependencies": {
    "@babel/core": "^7.20.0",
    "@babel/preset-env": "^7.21.5",
    "@babel/runtime": "^7.20.0",
    "@react-native-community/eslint-config": "^3.2.0",
    "@testing-library/jest-native": "^5.4.3",
    "@testing-library/react-native": "^12.5.1",
    "@tsconfig/react-native": "^2.0.2",
    "@types/jest": "^29.2.1",
    "@types/react": "^18.0.24",
    "@types/react-test-renderer": "^18.0.0",
    "babel-jest": "^29.2.1",
    "eslint": "^8.19.0",
    "eslint-plugin-jest-dom": "^5.4.0",
    "eslint-plugin-local-rules": "^2.0.1",
    "eslint-plugin-testing-library": "^6.2.2",
    "eslint-plugin-unused-imports": "^4.0.0",
    "jest": "^29.2.1",
    "metro-react-native-babel-preset": "0.73.9",
    "prettier": "^2.4.1",
    "react-test-renderer": "18.2.0",
    "typescript": "4.8.4"
  },
  "browserslist": {
    "production": [
      ">0.2%",
      "not dead",
      "not op_mini all"
    ],
    "development": [
      "last 1 chrome version",
      "last 1 firefox version",
      "last 1 safari version"
    ]
  },
  "reactNativePermissionsIOS": [
    "Camera"
  ]
}

iOS Setup

n/a

Android Setup

buildscript {
    ext {
        buildToolsVersion = "34.0.0"
        minSdkVersion = 24
        targetSdkVersion = 34
        compileSdkVersion = 34
        androidXAnnotation = "1.1.0"
        androidXBrowser = "1.0.0"
        supportLibVersion = "28.0.0"

        // We use NDK 23 which has both M1 support and is the side-by-side NDK version from AGP.
        ndkVersion = "23.1.7779620"

        // https://docs.datadoghq.com/real_user_monitoring/mobile_and_tv_monitoring/setup/reactnative/#setup
        // https://kotlinlang.org/docs/releases.html#release-details
        kotlinVersion = "1.9.25"
    }
    constraints {
        implementation("org.jetbrains.kotlin:kotlin-stdlib-jdk7:1.8.0") {
            because("kotlin-stdlib-jdk7 is now a part of kotlin-stdlib")
        }
        implementation("org.jetbrains.kotlin:kotlin-stdlib-jdk8:1.8.0") {
            because("kotlin-stdlib-jdk8 is now a part of kotlin-stdlib")
        }
    }

Device Information

all android, primary testing on Samsung A15

Other relevant information

No response

marco-saia-datadog commented 1 month ago

Hi @compwron, my apologies for the long wait!

At a first glance it looks like a conflict with Android dependencies. Could you please share your gradle dependencies here for me to take a look at them?

It would also help to copy and paste the output of ./gradlew app:dependencies, to have a detailed overview of your dependency tree.

compwron commented 1 month ago

Hi @compwron, my apologies for the long wait!

At a first glance it looks like a conflict with Android dependencies. Could you please share your gradle dependencies here for me to take a look at them?

It would also help to copy and paste the output of ./gradlew app:dependencies, to have a detailed overview of your dependency tree.

Thanks for the reply! My team upgraded react-native to 0.75.4 and stopped having this error, so it's definitely a conflict of some kind. Here is the build.gradle that produces the error:

buildscript {
    ext {
        buildToolsVersion = "34.0.0"
        minSdkVersion = 24
        targetSdkVersion = 34
        kotlinVersion = "1.8.21" // https://docs.datadoghq.com/real_user_monitoring/mobile_and_tv_monitoring/setup/reactnative/
        compileSdkVersion = 34
        androidXAnnotation = "1.1.0"
        androidXBrowser = "1.0.0"
        supportLibVersion = "28.0.0"

        // We use NDK 23 which has both M1 support and is the side-by-side NDK version from AGP.
        ndkVersion = "23.1.7779620"
    }
    repositories {
        google()
        mavenCentral()
        jcenter()
    }
    dependencies {
        classpath('com.android.tools.build:gradle:7.4.2')
        classpath("com.facebook.react:react-native-gradle-plugin")
        classpath("com.google.gms:google-services:4.4.2")
        classpath("io.sentry:sentry-android-gradle-plugin:4.1.1")
    }

    allprojects {
        repositories {
            mavenLocal()
            maven {
                // All of React Native (JS, Obj-C sources, Android binaries) is installed from npm
                url("$rootDir/../node_modules/react-native/android")
            }
            maven {
                // Android JSC is installed from npm
                url("$rootDir/../node_modules/jsc-android/dist")
            }

            google()
            jcenter()
//         jitpack is how we import dependency from github: 'com.github.KeepSafe:ReLinker:1.4.3'
            maven { url 'https://www.jitpack.io' }
        }
    }
}
compwron commented 1 month ago

app:dependencies https://gist.github.com/compwron/db2136916123a8e996f0baeb1171b831