Skip to content

Crash on physical device (Android 10) using useFreeRasp – lateinit property threatDispatcher has not been initialized #143

@raizen-denilsonrp

Description

@raizen-denilsonrp

Crash on physical device (Android 10) using useFreeRasplateinit property threatDispatcher has not been initialized

Description

Hi,

I'm integrating freeRASP React Native v4.5.0 following the latest documentation and using the recommended useFreeRasp hook.

The library works correctly on the Android emulator, but when running the same build on a physical device, the app crashes during startup.

The crash happens immediately after the app resumes, and the stack trace indicates that threatDispatcher was not initialized.

I would like to know if this could be related to running on an older Android version (Android 10) or if there might be an initialization race condition on physical devices.


Environment

  • freeRASP React Native: 4.5.0
  • React Native: 0.81.5
  • Expo: 54.0.31
  • Android Emulator: works correctly
  • Physical Device: crashes
  • Device Android Version: Android 10
  • Architecture: React Native + Expo Router

Integration approach

I am using the recommended hook integration from the documentation.

Import used in the project:

import { useFreeRasp, ThreatEventActions } from "freerasp-react-native";

const actions: ThreatEventActions = {
  started: () => console.warn("[freeRASP] started"),
  appIntegrity: () => console.warn("[freeRASP] appIntegrity"),
  privilegedAccess: () => console.warn("[freeRASP] privilegedAccess"),
  hooks: () => console.warn("[freeRASP] hooks"),
  initializationError: (err) => console.warn("[freeRASP] initializationError", err),
};

useFreeRasp(config, actions);

Configuration used:

const config = {
  androidConfig: {
    packageName: "my.package.name",
    certificateHashes: ["my-hash"],
  },
  watcherMail: "email@example.com",
  isProd: false,
};

Steps to reproduce

  1. Install the app on a physical Android device
  2. Launch the app
  3. The app crashes during initialization

Crash log

03-10 09:44:30.464 29790 29790 E AndroidRuntime: Process: my.package.name, PID: 29790
03-10 09:44:30.464 29790 29790 E AndroidRuntime: q9.K: lateinit property threatDispatcher has not been initialized
03-10 09:44:30.464 29790 29790 E AndroidRuntime: at Ub.z.b(SourceFile:8)
03-10 09:44:30.464 29790 29790 E AndroidRuntime: at Ub.v.onHostResume(SourceFile:1)
03-10 09:44:30.464 29790 29790 E AndroidRuntime: at com.facebook.react.bridge.ReactContext$1.run(SourceFile:18)
03-10 09:44:30.464 29790 29790 E AndroidRuntime: at android.os.Handler.handleCallback(Handler.java:883)
03-10 09:44:30.464 29790 29790 E AndroidRuntime: at android.os.Handler.dispatchMessage(Handler.java:100)
03-10 09:44:30.464 29790 29790 E AndroidRuntime: at com.facebook.react.bridge.queue.MessageQueueThreadHandler.dispatchMessage(SourceFile:6)
03-10 09:44:30.464 29790 29790 E AndroidRuntime: at android.os.Looper.loop(Looper.java:237)
03-10 09:44:30.464 29790 29790 E AndroidRuntime: at android.app.ActivityThread.main(ActivityThread.java:7807)
03-10 09:44:30.464 29790 29790 E AndroidRuntime: at java.lang.reflect.Method.invoke(Native Method)
03-10 09:44:30.464 29790 29790 E AndroidRuntime: at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:493)
03-10 09:44:30.464 29790 29790 E AndroidRuntime: at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1047)

Additional observation

The same build works correctly on the Android emulator running Android 10, but fails on a physical device running Android 10.

Could this issue be related to:

  • older Android versions?
  • initialization timing between React Native lifecycle and freeRASP initialization?
  • a known issue with onHostResume on physical devices?

If helpful, I can provide additional logs or a minimal reproduction.

Thanks!

Metadata

Metadata

Assignees

Labels

bugSomething isn't working

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions