在 react-native 中调试原生 java 代码 [英] Debug native java code in react-native

查看:64
本文介绍了在 react-native 中调试原生 java 代码的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有没有办法为使用 react-native 构建的 Android 应用程序调试本机 Java 代码.具体来说,我想调试我在 react-native 应用程序中使用的第三方 Android 包.可能有关于如何调试 js 代码的博客文章和 stackoverflow 问题,但我没有找到任何描述如何调试原生 java 代码的文章.我尝试将第三方 Android 包导入 Android Studio 并尝试在调试器中运行它,但实际上没有发生我所期望的.

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!

推荐答案

您可以在 Android Studio 中打开项目并在那里调试任何本机代码(添加断点、逐步调试等).

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

请务必事先启动 React Native 打包程序.然后在调试模式下从 Android Studio 启动您的应用.

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

更多信息:https://developer.android.com/studio/debug/index.html

这篇关于在 react-native 中调试原生 java 代码的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆