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

运行Baseline Profile Generator生成基线配置文件时抛出IllegalStateException异常

运行Baseline Profile Generator生成基线配置文件时抛出IllegalStateException异常

问题分析

你遇到的这个问题是Android Benchmark Macro库与Android 14设备的输出格式不兼容导致的。从报错日志能明确看到:

java.lang.IllegalStateException: Expected pm dump-profiles stdout to be either black or Profile saved to '/data/misc/profman/com.app.myapp-primary.prof.txt' but was Waiting for app processes to flush profiles... App processes flushed profiles in 0ms Profile saved to '/data/misc/profman/com.app.myapp-primary.prof.txt'

旧版本的Benchmark库对pm dump-profiles命令的输出做了严格的硬匹配校验,只接受两种结果:要么是空输出,要么只有Profile saved to...这一行。但Android 14系统中,这个命令多输出了两行额外日志:

  • Waiting for app processes to flush profiles...
  • App processes flushed profiles in 0ms

这就直接触发了库中的校验逻辑,抛出了IllegalStateException。你之前尝试的清理项目、无效缓存操作对这个问题无效,因为它本质是依赖版本与系统版本的兼容性问题,而非缓存或编译产物问题。

解决方案

最直接有效的修复方式是升级Benchmark相关依赖到最新稳定版本——谷歌已经在后续版本中修复了这个输出格式不兼容的问题,支持处理多行的pm dump-profiles输出。

具体操作:

在你的App模块的build.gradle(或build.gradle.kts)中,将Benchmark Macro相关的依赖版本升级到1.2.0及以上(推荐使用最新稳定版):

dependencies {
    // 基准测试核心依赖
    androidTestImplementation "androidx.benchmark:benchmark-macro-junit4:1.2.0"
    debugImplementation "androidx.benchmark:benchmark-macro:1.2.0"
    
    // 保持其他依赖不变...
}

升级完成后,重新同步项目,再运行Baseline Profile Generator测试,就能正常完成基线配置文件的生成了。

临时备选方案(若暂时无法升级依赖)

如果因为项目限制暂时不能升级依赖,可以尝试使用Android 13及以下版本的设备运行生成器——这些系统的pm dump-profiles输出格式符合旧版Benchmark库的校验逻辑,不会触发这个异常。但这只是临时 workaround,长远来看还是推荐升级依赖以适配Android 14。

内容来源于stack exchange

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.04.07 13:29:33