无法连接到远程进程。正在中止调试会话。连接调试器确定按钮呈灰色

Beh*_*ian 4 debugging android android-studio

当我尝试调试应用程序时,模拟器停留在“等待调试器”状态。同时,在调试选项卡中,可以看到AS正在“等待应用程序上线”。但过了一会儿显示“无法连接到远程进程。正在中止调试会话”。作为进一步的尝试,正常运行应用程序后,我尝试“将调试器附加到 Android 进程”。“选择进程”对话框打开,模拟器上的进程正确显示,但“确定”按钮呈灰色!

Android Studio 版本:2020.3.1 补丁 4:操作系统类型和版本:Windows 7 v6.1 Service Pack 1 内部版本:AI-203.7717.56.2031.7784292、202110010236、

AI-203.7717.56.2031.7784292,JRE 11.0.10+0-b96-7249189x64 JetBrains sro,操作系统 Windows 7(amd64) v6.1 Service Pack 1,屏幕 1366.0x768.0

AS:北极狐| 2020.3.1 补丁3;Kotlin 插件:203-1.6.0-release-798-AS7717.8;Android Gradle 插件:7.0.3;摇篮:7.0.2;Gradle JDK:版本11.0.10;NDK:来自 local.properties:(未指定),来自 SDK 的最新版本:(未找到);LLDB:未找到固定版本 3.1,来自 SDK 的最新版本:(未找到包);CMake:来自 local.properties:(未指定),来自 SDK 的最新版本:(未找到),来自 PATH:(未找到)来源:user_sentiment_feedback

我在网上阅读并实施了所有可能的解决方案,但没有成功。我仍然遇到“无法连接到远程进程。正在中止调试会话。” 这种情况发生在所有模拟器和真实手机上的所有应用程序上。

Yam*_*ion 5

就我而言,文件debuggable true中缺少参数app/build.gradle。添加它并将我的应用程序重建到设备解决了问题:

app/build.gradle

android {
    buildTypes {
        debug {
            // Check if you have this parameter enabled.
            // Add if missing and rebuild your app to device. 
            debuggable true
        }
    }
}
Run Code Online (Sandbox Code Playgroud)