Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Debug native java code in react-native

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!

like image 853
Varun Gupta Avatar asked Jun 24 '16 06:06

Varun Gupta


People also ask

How do I debug Java in React Native?

Show activity on this post. 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.

How do you debug React Native with React Native debugger?

Connecting a React Native app to React Native Debugger To connect your app with React Native Debugger, you need to run your app and start debug mode. To start debug mode, shake your mobile device or press Command + Shift + Z or Ctrl + M and choose the debug option.


2 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

like image 82
Jean Regisser Avatar answered Oct 18 '22 01:10

Jean Regisser


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.

like image 4
Jepolo Avatar answered Oct 18 '22 00:10

Jepolo