How do I fix “Could not connect to remote process” while trying to debug the application?

时光怂恿深爱的人放手 提交于 2020-02-21 10:26:12

问题


I am making a android studio project and I try to debug my application.

Running the application works fine, but when I try to debug it I get this error:

Could not connect to remote process. Aborting debug session.

What can I do to fix the issue?


回答1:


You need to restart the ADB.

kill adb.exe process.

how to restart ADB manually from Android Studio




回答2:


Check if you have selected the right Build Variant, usually "release" comes with debuggable false

Example:

 buildTypes {
        release {
            debuggable false
            ....
        }
    }

is not recommendable change release to debuggable true, just change the right variant

   debug {
        debuggable true
        ....
    }



回答3:


In My case, For some reason I disabled Instant run and it has changed the Launch value from "Default Activity" to "Nothing" in "Run/Debug configurations". So always it says "Could not connect to remote process. Aborting debug session" and I was not able to debug. I enabled Instant and changed the Launch value from "Nothing" to "Default Activity" in "Run/Debug configurations" and it worked. Hope this will help some one.

(to get Run/Debug configurations, click "app" drop down and click Edit Configurations)




回答4:


In command line :

adb kill-server && adb start-server

This command will restart ADB




回答5:


By default Android Studio builds the debug version of the application. However, during the publishing phase you may have switched to the release one as the tutorial suggests.

ADB won't be able to attach to the application unless you revert to the debug configuration or you allow to the debug the release one.

If nothing of this works, you may resort in restarting ADB as explianed in How to restart ADB manually from Android Studio

Revert to debug configuration

  1. Choose Build->Select Build Variant
  2. Pick up debug in the second column
  3. Deploy the application again

Allow the release version to be debugged

  1. Select your application node in the tree
  2. Right click and choose Open Module Settings (or hit F4)
  3. Select Build Variants on the left
  4. Choose release on the right
  5. Set debuggable to true
  6. Apply and deploy the application

Keep in mind that your life won't be easy as your application may be optimized and therefore not debugger friendly (e.g. you might not be able to step in certain methods, or view some local variables).



来源:https://stackoverflow.com/questions/53962831/how-do-i-fix-could-not-connect-to-remote-process-while-trying-to-debug-the-app

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!