我正在尝试为我的应用程序实现基线配置文件(官方文档)。按照本视频(通过基线配置文件提高性能)中指示的步骤,如果我使用DebugBuildVariant,我可以创建benchmark-prof.txt文件以缩短启动时间。但是当我尝试创建用于发布的基线-prof 文件时,出现以下异常:
./gradlew :macrobenchmark:pixel2Api31BenchmarkAndroidTest -P android.testInstrumentationRunnerArguments.class=com.example.BaselineProfileGenerator
Run Code Online (Sandbox Code Playgroud)
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).
Run Code Online (Sandbox Code Playgroud)
这就是我们的BaselineProfileGenerator的样子:
./gradlew :macrobenchmark:pixel2Api31BenchmarkAndroidTest -P android.testInstrumentationRunnerArguments.class=com.example.BaselineProfileGenerator
Run Code Online (Sandbox Code Playgroud)
如果我配置调试基准,它会很好地工作:
benchmark {
initWith buildTypes.debug
signingConfig signingConfigs.debug
matchingFallbacks = ['debug']
debuggable false
proguardFiles('benchmark-rules.pro')
}
Run Code Online (Sandbox Code Playgroud)
但是将其配置为Release,当您尝试生成它时,基准测试会引发之前的异常。
benchmark {
initWith buildTypes.release …Run Code Online (Sandbox Code Playgroud)