debugging Android Studio -未连接调试服务器时销毁

g0czyy6m  于 2022-11-30  发布在  Android
关注(0)|答案(1)|浏览(200)

因此,我开始在Android Studio中 * a使用一些原生C++代码创建一个应用。我的手机是Realme 8i**。我已经将我的应用部署到这款手机上。在我尝试调试我的应用之前,一切都运行得很好。当我启动调试时,我甚至可以命中断点并在调试窗口中看到一些变量。但几秒钟后,与手机的连接中断,我的应用程序立即崩溃。目前这是一个非常简单的应用程序,所以它不应该像那样崩溃。
Adnroid Studio中调试窗口的唯一消息是:

Debugger attached to process 29096
destroying when not connected to debugserver

Process finished with exit code 22

下面是来自logcat的日志(警告级别或更高级别的所有内容):

2022-11-27 13:57:49.724 29568-29568/com.acme.acmecorptestapp02 W/ActivityThread: Application com.acme.acmecorptestapp02 is waiting for the debugger on port 8100...
2022-11-27 13:57:51.631 29568-29584/com.acme.acmecorptestapp02 W/System: A resource failed to call close. 
2022-11-27 13:57:57.787 29568-29568/com.acme.acmecorptestapp02 E/ANR_LOG: >>> msg's executing time is too long
2022-11-27 13:57:57.787 29568-29568/com.acme.acmecorptestapp02 E/ANR_LOG: Blocked msg = { when=-8s145ms what=110 target=android.app.ActivityThread$H obj=AppBindData{appInfo=ApplicationInfo{3d00b62 com.acme.acmecorptestapp02}} } , cost  = 8083 ms
2022-11-27 13:57:57.787 29568-29568/com.acme.acmecorptestapp02 E/ANR_LOG: >>>Current msg List is:
2022-11-27 13:57:57.788 29568-29568/com.acme.acmecorptestapp02 E/ANR_LOG: Current msg <1> = { when=-8s144ms what=9999 target=android.app.ActivityThread$H }
2022-11-27 13:57:57.790 29568-29568/com.acme.acmecorptestapp02 E/ANR_LOG: Current msg <2> = { when=-8s142ms what=159 target=android.app.ActivityThread$H obj=ClientTransaction LaunchActivityItem,ResumeActivityItem }
2022-11-27 13:57:57.792 29568-29568/com.acme.acmecorptestapp02 E/ANR_LOG: Current msg <3> = { when=-8s141ms what=159 target=android.app.ActivityThread$H obj=ClientTransaction TopResumedActivityChangeItem, }
2022-11-27 13:57:57.793 29568-29568/com.acme.acmecorptestapp02 E/ANR_LOG: Current msg <4> = { when=-8s124ms what=0 target=android.app.ActivityThread$H callback=com.android.internal.util.function.pooled.PooledLambdaImpl }
2022-11-27 13:57:57.794 29568-29568/com.acme.acmecorptestapp02 E/ANR_LOG: Current msg <5> = { when=-7s809ms what=149 target=android.app.ActivityThread$H obj=android.os.BinderProxy@2d8e4f3 }
2022-11-27 13:57:57.794 29568-29568/com.acme.acmecorptestapp02 E/ANR_LOG: Current msg <6> = { when=-7s124ms what=0 target=android.app.ActivityThread$H callback=android.app.-$$Lambda$ActivityThread$A4ykhsPb8qV3ffTqpQDklHSMDJ0 }
2022-11-27 13:57:57.794 29568-29568/com.acme.acmecorptestapp02 E/ANR_LOG: >>>CURRENT MSG DUMP OVER<<<
2022-11-27 13:57:57.927 29568-29659/com.acme.acmecorptestapp02 E/QT: [QT]file does not exist
2022-11-27 13:57:58.244 29568-29568/com.acme.acmecorptestapp02 E/OplusCustomizeRestrictionManager: sInstance is null, start a new sInstance
2022-11-27 13:57:58.801 29568-29568/com.acme.acmecorptestapp02 W/mecorptestapp0: Accessing hidden method Landroid/view/View;->computeFitSystemWindows(Landroid/graphics/Rect;Landroid/graphics/Rect;)Z (greylist, reflection, allowed)
2022-11-27 13:57:58.802 29568-29568/com.acme.acmecorptestapp02 W/mecorptestapp0: Accessing hidden method Landroid/view/ViewGroup;->makeOptionalFitsSystemWindows()V (greylist, reflection, allowed)

我该如何解决这个问题?

blmhpbnm

blmhpbnm1#

所以我做了更多的测试,结果发现我的问题并不是因为我的项目中有C++代码。这个问题是因为在代码中错误的位置设置了断点。它是在主类的onCreate中设置的。将断点移到我的代码中的另一行解决了这个问题(在本例中是移到onClick函数)。
因为这个奇怪的问题,比我不能在任何地方设置断点还要可悲......如果我能找到更好的解决方案,我会编辑这个答案。
编辑:它也可以在模拟器上正常工作泛指el 2 XL在Android Studio中。我仍然不知道为什么它不能在真实的的手机上工作...

相关问题