问题
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
- Choose Build->Select Build Variant
- Pick up
debug
in the second column - Deploy the application again
Allow the release version to be debugged
- Select your application node in the tree
- Right click and choose Open Module Settings (or hit F4)
- Select Build Variants on the left
- Choose
release
on the right - Set
debuggable
totrue
- 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