我正在学习使用 Android Studio 3.1.4 在 WearOS 下开发表盘。我的调试器有问题。
看来我无法直接在调试模式下运行应用程序(Shift-F9)。如果这样做,我会系统地收到以下消息,尽管已在手表(模拟器或真实手表(华为手表 2))上进行了授权调试:
08/24 09:03:00: Launching wearmodule
$ adb push /path/wearmodule/build/outputs/apk/debug/wearmodule-debug.apk /data/local/tmp/com.example.wearmodule
$ adb shell pm install -t -r "/data/local/tmp/com.example.wearmodule"
Success
Waiting for application to come online: com.example.wearmodule.test | com.example.wearmodule
Waiting for application to come online: com.example.wearmodule.test | com.example.wearmodule
Waiting for application to come online: com.example.wearmodule.test | com.example.wearmodule
Connecting to com.example.wearmodule
Waiting for application to start debug server
Waiting for application to come online: com.example.wearmodule.test | com.example.wearmodule
Connecting to com.example.wearmodule
Waiting for application to start debug server
Waiting for application to come online: com.example.wearmodule.test | com.example.wearmodule
Connecting to com.example.wearmodule
Waiting for application to start debug server
Waiting for application to come online: com.example.wearmodule.test | com.example.wearmodule
Connecting to com.example.wearmodule
Waiting for application to start debug server
Waiting for application to come online: com.example.wearmodule.test | com.example.wearmodule
Connecting to com.example.wearmodule
Waiting for application to start debug server
Waiting for application to come online: com.example.wearmodule.test | com.example.wearmodule
Connecting to com.example.wearmodule
Waiting for application to start debug server
Waiting for application to come online: com.example.wearmodule.test | com.example.wearmodule
Connecting to com.example.wearmodule
Waiting for application to start debug server
Waiting for application to come online: com.example.wearmodule.test | com.example.wearmodule
Connecting to com.example.wearmodule
Waiting for application to start debug server
Waiting for application to come online: com.example.wearmodule.test | com.example.wearmodule
Connecting to com.example.wearmodule
Waiting for application to start debug server
Waiting for application to come online: com.example.wearmodule.test | com.example.wearmodule
Connecting to com.example.wearmodule
Waiting for application to start debug server
Waiting for application to come online: com.example.wearmodule.test | com.example.wearmodule
Connecting to com.example.wearmodule
Waiting for application to start debug server
Waiting for application to come online: com.example.wearmodule.test | com.example.wearmodule
Connecting to com.example.wearmodule
Waiting for application to start debug server
Waiting for application to come online: com.example.wearmodule.test | com.example.wearmodule
Connecting to com.example.wearmodule
Waiting for application to start debug server
Waiting for application to come online: com.example.wearmodule.test | com.example.wearmodule
Connecting to com.example.wearmodule
Waiting for application to start debug server
Could not connect to remote process. Aborting debug session.
如果我理解正确,调试服务器必须在手表本身上启动。我怎样才能做到这一点?
如果我想调试手表,唯一的选择是以正常模式 (Shift-F10) 运行应用程序,然后将调试器附加到进程。
这并不理想,因为它不允许我对代码的初始化过程进行故障排除。特别是initializeWatchFace()
, onCreate()
or之类的方法onSurfaceChanged()
不能调试,真的很烦人。
手表本身,清单中,某处有什么特别的事情可以解决这个问题吗?是否可以将其与我的应用程序没有活动的事实联系起来(如 Google CodeLab 中所述)。我似乎将这些问题与活动管理联系起来的消息。