Код: Выделить всё
package com.google.baselineprofile
import androidx.benchmark.macro.BaselineProfileMode
import androidx.benchmark.macro.CompilationMode
import androidx.benchmark.macro.StartupMode
import androidx.benchmark.macro.StartupTimingMetric
import androidx.benchmark.macro.junit4.MacrobenchmarkRule
import androidx.test.ext.junit.runners.AndroidJUnit4
import androidx.test.filters.LargeTest
import org.junit.Rule
import org.junit.Test
import org.junit.runner.RunWith
@RunWith(AndroidJUnit4::class)
@LargeTest
class StartupBenchmarks {
@get:Rule
val rule = MacrobenchmarkRule()
@Test
fun startupCompilationNone() =
benchmark(CompilationMode.None())
@Test
fun startupCompilationBaselineProfiles() =
benchmark(CompilationMode.Partial(BaselineProfileMode.Require))
private fun benchmark(compilationMode: CompilationMode) {
rule.measureRepeated(
packageName = "com.example.baselineprofiles_codelab",
metrics = listOf(StartupTimingMetric()),
compilationMode = compilationMode,
startupMode = StartupMode.COLD,
iterations = 10,
setupBlock = {
pressHome()
},
measureBlock = {
startActivityAndWait()
waitForAsyncContent()
}
)
}
}
Код: Выделить всё
java.lang.IllegalStateException: Failed to compile (out=Error: Failed to compile !)
at androidx.benchmark.macro.CompilationMode$Companion.cmdPackageCompile$benchmark_macro_release(CompilationMode.kt:434)
at androidx.benchmark.macro.CompilationMode$Partial.compileImpl$benchmark_macro_release(CompilationMode.kt:307)
at androidx.benchmark.macro.CompilationMode.resetAndCompile$benchmark_macro_release(CompilationMode.kt:114)
at androidx.benchmark.macro.CompilationMode.resetAndCompile$benchmark_macro_release$default(CompilationMode.kt:75)
at androidx.benchmark.macro.MacrobenchmarkKt.macrobenchmark(Macrobenchmark.kt:237)
at androidx.benchmark.macro.MacrobenchmarkKt.macrobenchmarkWithStartupMode(Macrobenchmark.kt:436)
at androidx.benchmark.macro.junit4.MacrobenchmarkRule.measureRepeated(MacrobenchmarkRule.kt:107)
at com.google.baselineprofile.StartupBenchmarks.benchmark(StartupBenchmarks.kt:49)
Дополнительный контекст:
- Устройство: OPPO A53
- Версия ОС: Android 12 (ColorOS 12.1)
- Ошибка Тест: StartupCompilationBaselineProfiles
- Рабочий тест: startCompilationNone
Почему эта проблема возникает на моем устройстве OPPO A53? Есть ли что-то особенное в этом устройстве или ColorOS, что приводит к сбою теста CompilationMode.Partial? Как я могу исправить или обойти эту проблему?
Подробнее здесь: https://stackoverflow.com/questions/792 ... stateexcep
Мобильная версия