You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Android Studio双调试模式下控制台无输出问题求助

问题描述

Windows系统下,在Java Android应用中通过CMake和Gradle引入C++开发,功能运行正常,但调试时Java日志无法在控制台显示。启动调试时会出现app和app-java两个进程,均未显示预期内容(如触摸事件日志)。

调试日志如下:

app进程日志

12/05 20:12:12: Launching 'app' on samsung.
Install successfully finished in 6 s 531 ms.
$ adb shell am start -n "com.agragps.agragps/com.agragps.agragps.MainActivity" -a android.intent.action.MAIN -c android.intent.category.LAUNCHER -D
Waiting for application to come online: com.agragps.agragps
Connecting to com.agragps.agragps
Now Launching Native Debug Session
$ adb shell cat /data/local/tmp/lldb-server | run-as com.agragps.agragps sh -c 'cat > /data/data/com.agragps.agragps/lldb/bin/lldb-server && chmod 700 /data/data/com.agragps.agragps/lldb/bin/lldb-server'
$ adb shell cat /data/local/tmp/start_lldb_server.sh | run-as com.agragps.agragps sh -c 'cat > /data/data/com.agragps.agragps/lldb/bin/start_lldb_server.sh && chmod 700 /data/data/com.agragps.agragps/lldb/bin/start_lldb_server.sh'
Starting LLDB server: /data/data/com.agragps.agragps/lldb/bin/start_lldb_server.sh /data/data/com.agragps.agragps/lldb unix-abstract /com.agragps.agragps-0 platform-1670296340839.sock "lldb process:gdb-remote packets"
Debugger attached to process 18174

app-java进程日志

Connected to the target VM, address: 'localhost:53082', transport: 'socket'
解决方法
  • 切换日志进程目标
    同时调试Java和Native代码时,Android Studio会拆分两个进程控制台:app对应Native调试,app-java对应Java调试。在日志面板的进程选择下拉框中切换到app-java,然后取消日志过滤(比如选择No Filters),确保日志未被屏蔽。

  • 检查日志配置
    打开Run/Debug Configurations,找到当前调试配置的Logcat标签页:

    1. 确认Logcat选项已启用;
    2. 将日志级别设为Verbose,清空错误的过滤条件;
    3. 勾选Show logcat automatically,保证调试时自动加载日志面板。
  • 用ADB命令直接查看日志
    若IDE控制台仍无输出,在命令行执行:

    adb logcat -s com.agragps.agragps
    

    直接获取应用的所有日志,包括Java层输出内容。

  • 验证调试配置
    检查Module级build.gradle的调试配置:

    android {
        buildTypes {
            debug {
                debuggable true
                jniDebuggable true
            }
        }
        externalNativeBuild {
            cmake {
                path "CMakeLists.txt"
            }
        }
    }
    

    确保debuggable和jniDebuggable均为true,保证Java与Native调试正常联动。

  • 重启IDE与设备
    重启Android Studio和连接的设备,清除应用缓存后重新调试,可解决进程关联异常问题。

内容的提问来源于stack exchange,提问作者cj-

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.08.10 00:15:35