我配置了一个基准模块,并为项目创建了一个基线配置文件,并按照这里的https://developer.android.com/studio/profile/baselineprofiles说明将其保存在应用程序中。
我还添加了基准:
@RunWith(AndroidJUnit4::class)
class BaselineProfileBenchmark {
@get:Rule
val benchmarkRule = MacrobenchmarkRule()
@Test
fun startupNoCompilation() {
startup(CompilationMode.None())
}
@Test
fun startupBaselineProfile() {
startup(
CompilationMode.Partial(
baselineProfileMode = BaselineProfileMode.Require
)
)
}
private fun startup(compilationMode: CompilationMode) {
benchmarkRule.measureRepeated(
packageName = "com.example.app",
metrics = listOf(StartupTimingMetric()),
iterations = 10,
startupMode = StartupMode.COLD,
compilationMode = compilationMode
) {
pressHome()
startActivityAndWait()
}
}
}startupBaselineProfile()测试失败,异常“此设备版本不支持基线配置文件”。我试着用最新的Android版本在不同的Pixel和Samsung设备上运行它,但是到处都会抛出同样的异常。
这些基线配置文件是否有效?
发布于 2022-04-21 07:25:15
2022年10月更新
使用修复问题的androidx.profileinstaller版本1.3.0-alpha01或更高版本(或发布时的1.2.1版本)。
原始答案
目前,基线概况存在一些已知的问题:
请注意,profileinstaller可以与库一起添加(例如,jetpack撰写),因此请确保将它添加到依赖项中以覆盖版本。
发布于 2022-05-16 12:05:52
确保将profileinstaller依赖项添加到目标模块(通常是app模块)
implementation "androidx.profileinstaller:profileinstaller:1.2.0-beta01"https://stackoverflow.com/questions/71174855
复制相似问题