Debugging a React Native app from an APK running on a physical Android device is slightly different from debugging in development mode (npx react-native run-android
). Once you build a release APK, it's optimized, minified, and doesn't have debugging tools attached by default. Here's a structured approach depending on whether you're using a debug build APK or a release build APK.
If you built a debug APK (debug.apk
), debugging is easy:
-
Enable Developer Options and USB Debugging on your device.
-
Connect the physical device via USB.
-
Install the debug APK:
adb install app-debug.apk
-
Open the app on your phone.
-
Shake the device (or press
Ctrl + M
orCmd + M
on emulator) to open the Developer Menu. -
Choose "Debug JS Remotely":
- It opens Chrome DevTools where you can debug console logs, inspect network requests, set breakpoints, etc.
-
Alternatively, use:
adb logcat *:S ReactNative:V ReactNativeJS:V
to see logs from React Native and JS side.
Release APKs are minified, obfuscated, and don't support Dev Menu. So you must use other tools:
-
Run this in terminal:
adb logcat *:S ReactNative:V ReactNativeJS:V
-
Add
console.log
,console.error
in JS files to see output here.
Use libraries like react-native-logs to save and view logs easily even in release mode.
If your app is built with Flipper enabled, you can use it in release too (though not common due to bundle size). To enable Flipper in release:
- Modify
android/app/proguard-rules.pro
to keep Flipper classes - Be aware: This is not recommended for production
Use tools like:
They can collect JS and native crashes and stack traces even in release builds.
If you bundle JS manually and inject debug logs:
react-native bundle --platform android --dev true --entry-file index.js --bundle-output index.android.bundle
You can enable better JS logging even in non-debug builds.
To debug release issues meaningfully (e.g. in Sentry or Flipper):
react-native bundle \
--platform android \
--dev false \
--entry-file index.js \
--bundle-output index.android.bundle \
--sourcemap-output index.android.bundle.map
Upload the .map
file to your error tracking tool.
Scenario | Tools/Methods |
---|---|
Debug APK | Dev Menu, Chrome DevTools, adb logcat |
Release APK | adb logcat , Crashlytics, Sentry, custom logs |
Network Issues | Use proxy tools like Charles, mitmproxy |
Native Crashes | Android Studio Profiler, adb logcat , Crashlytics |
JS Crashes | Console logs + Sentry with source maps |
Let me know if you want a setup guide for any of these tools (like Sentry or Crashlytics), or if you want to debug using Flipper or Hermes.