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

生成Release版本Baseline Profile时遇启动确认异常求助

Release构建变体生成Baseline Profiles时抛出启动完成确认异常

我正在为应用实现Baseline Profiles,按照官方视频步骤操作时,Debug构建变体可成功生成baseline-prof.txt以优化启动时间,但切换为Release配置运行基准测试时,出现如下异常。

执行命令

./gradlew :macrobenchmark:pixel2Api31BenchmarkAndroidTest -P android.testInstrumentationRunnerArguments.class=com.example.BaselineProfileGenerator

异常信息

com.example.BaselineProfileGenerator > generate[pixel2Api31] FAILED
        java.lang.IllegalStateException: Unable to confirm activity launch completion [] Please report a bug with the output of `adb shell dumpsys gfxinfo com.leinardi.forlago framestats`
                at androidx.benchmark.macro.MacrobenchmarkScope.startActivityImpl(MacrobenchmarkScope.kt:179)
Tests on pixel2Api31 failed: There was 1 failure(s).

基准测试代码

@OptIn(ExperimentalBaselineProfilesApi::class)
@RunWith(AndroidJUnit4ClassRunner::class)
class BaselineProfileGenerator {
    @get:Rule
    val rule = BaselineProfileRule()

    @Test
    fun generate() {
        rule.collectBaselineProfile("com.leinardi.forlago") {
            pressHome()
            startActivityAndWait()
        }
    }
}

构建配置

  • Debug配置(运行正常):
benchmark {
    initWith buildTypes.debug
    signingConfig signingConfigs.debug
    matchingFallbacks = ['debug']
    debuggable false
    proguardFiles('benchmark-rules.pro')
}
  • Release配置(抛出异常):
benchmark {
    initWith buildTypes.release
    signingConfig signingConfigs.debug
    matchingFallbacks = ['release']
    debuggable false
    proguardFiles('benchmark-rules.pro')
}

环境信息

  • 使用组件:Baseline Profiles
  • 版本信息:AGP=7.3.0-rc01,uiautomator=2.2.0,benchmark-macro-junit4=1.1.0
  • 测试设备配置:
testOptions {
        managedDevices {
            devices {
                pixel2Api31(com.android.build.api.dsl.ManagedVirtualDevice) {
                    device = "Pixel 2"
                    apiLevel = 31
                    systemImageSource = "aosp"
                }
            }
        }
    }

内容的提问来源于stack exchange,提问作者J.Arroyo

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.08.21 19:36:29