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

非Compose Android项目录制Robo脚本触发Espresso不支持Compose错误

问题分析与解决方案

你的非Jetpack Compose项目触发Espresso录制工具的Compose不支持提示,核心原因是项目依赖树中存在间接引入的Compose相关依赖,Android Studio的录制工具会检测classpath中的Compose依赖,从而误判项目类型。以下是具体排查和解决步骤:

1. 定位引入Compose的第三方依赖

执行Gradle命令生成完整依赖树,搜索compose关键词找到根源:

./gradlew app:dependencies > dependencies.txt

打开生成的dependencies.txt文件,全局搜索compose,找到包含androidx.compose的依赖项,定位到具体是哪个第三方库引入的。

从你的依赖列表来看,com.kakao.sdk:v2-all:2.11.2是高风险候选:v2-all包含Kakao SDK的所有模块,其中可能包含Compose相关的UI组件。建议替换为仅引入你需要的模块(比如仅登录模块),避免冗余依赖:

// 替换之前的v2-all
implementation "com.kakao.sdk:v2-auth:2.11.2"
implementation "com.kakao.sdk:v2-user:2.11.2"
// 根据实际需求添加其他模块,不要用all包

2. 排除间接引入的Compose依赖

如果找到具体引入Compose的依赖,通过Gradle的exclude语法移除相关依赖:

implementation("第三方库坐标") {
    exclude group: 'androidx.compose'
    exclude group: 'androidx.compose.ui'
    // 根据实际搜索结果添加需要排除的组
}

3. 明确禁用Compose构建特性

在build.gradle(:app)的android块中明确添加禁用Compose的配置,避免工具误判:

android {
    // 其他配置...
    buildFeatures {
        compose false
        viewBinding true
    }
}

4. 更新Espresso版本(可选)

你当前使用的Espresso 3.4.0版本较旧,更新到最新稳定版可以修复部分检测逻辑问题:

androidTestImplementation 'androidx.test.espresso:espresso-core:3.5.1'
androidTestImplementation 'androidx.test.ext:junit:1.1.5'

额外优化建议

你的build.gradle(:app)中重复应用了kotlin-kapt插件,建议将其移到顶部的plugins块中,避免多次应用:

plugins {
    id 'com.android.application'
    id 'org.jetbrains.kotlin.android'
    id 'com.google.gms.google-services'
    id 'com.google.firebase.crashlytics'
    id 'kotlin-kapt' // 移到这里
}

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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.08.12 11:25:17