android studio 3.1.2 debug app, "attach debugger to android process" app 运行 in phone 找不到进程

android studio 3.1.2 debug app, "attach debugger to android process" can't find the process when app running in phone

看图片,应用程序 运行ning 在 phone 中。 enter image description here 然后在 phone 中,我找到开发人员选项->调试->Select 调试应用程序-> 未设置调试应用程序。 enter image description here enter image description here

大家好。我想调试 phone 中的应用程序,首先,我 运行 phone 中的应用程序。然后,我将 phone 连接到我的笔记本电脑使用电缆中。但在 as 中找不到应用程序进程。 然后,我用我的同事phone,在他的phone,我要调试的app在"debug application set"列表里,然后我就可以在as中调试app了。 我想知道,如何将应用进程添加到 "debug application set"。 谢谢大家

您需要运行调试应用程序版本。只需转到 Build Variants 面板和 select debug varian。 Release varian 也可以调试。在这种情况下,您必须在 buildTypes -> release 部分 debuggable true 属性 中的 build.gradle 和应用程序标记中的 AndroidManifest.xml 中指定添加属性 android:debuggable="true" tools:ignore="HardcodedDebugMode"。不要忘记在生产前回滚此更改。