Home » Android » android – Debug native java code in react-native

android – Debug native java code in react-native

Posted by: admin June 15, 2020 Leave a comment

Questions:

Is there a way to debug native java code for Android app built using react-native. Specifically, I want to debug a third party Android package that I am using in my react-native app. There are may blog posts and stackoverflow questions on how to debug the js code but I didn’t find any post describing how to debug native java code. I tried to just import the third party Android package into Android Studio and tried to run it in debugger but nothing really happened which I kind of expected.

Please let me know if and how it can be achieved. Thanks!

How to&Answers:

You can open the project in Android Studio and debug any native code there (add breakpoints, debug step by step, etc).

Be sure to launch the React Native packager beforehand. And then launch your app from Android Studio in debug mode.

More info: https://developer.android.com/studio/debug/index.html

Answer:

Launch the React Native packager by running ‘react-native start’ in the root directory of your React Native Project.

Open the “android” directory of your React Native project in Android Studio.

Then you will be able run and debug your React Native application from Android Studio.