You can display the console logs for an iOS or Android app by using the following commands in a terminal while the app is running:
You may also access these through Debug → Open System Log...
in the iOS Simulator or by running adb logcat *:S ReactNative:V ReactNativeJS:V
in a terminal while an Android app is running on a device or emulator.
If you're using Create React Native App, console logs already appear in the same terminal output as the packager.
If you're using Create React Native App, this is configured for you already.
On iOS devices, open the file RCTWebSocketExecutor.m
and change "localhost" to the IP address of your computer, then select "Debug JS Remotely" from the Developer Menu.
On Android 5.0+ devices connected via USB, you can use the adb
command line tool to setup port forwarding from the device to your computer:
adb reverse tcp:8081 tcp:8081
Alternatively, select "Dev Settings" from the Developer Menu, then update the "Debug server host for device" setting to match the IP address of your computer.
If you run into any issues, it may be possible that one of your Chrome extensions is interacting in unexpected ways with the debugger. Try disabling all of your extensions and re-enabling them one-by-one until you find the problematic extension.
In android/app/build.gradle
, add these lines in the dependencies
section:
In android/app/src/main/java/com/{yourAppName}/MainApplication.java
, add the following imports:
In android/app/src/main/java/com/{yourAppName}/MainApplication.java
add the function:
Run react-native run-android
In a new Chrome tab, open: chrome://inspect
, then click on 'Inspect device' (the one followed by "Powered by Stetho").
When working with native code, such as when writing native modules, you can launch the app from Android Studio or Xcode and take advantage of the native debugging features (setting up breakpoints, etc.) as you would in case of building a standard native app.
Improve this page by sending a pull request!