gradle 插件异常:通过托管设备运行基准配置文件测试时安装APK失败

aydmsdu9  于 2023-03-08  发布在  其他
关注(0)|答案(1)|浏览(213)

运行以下命令:

./gradlew :macro-benchmark:pixel2Api31ReleaseAndroidTest -P android.testInstrumentationRunnerArguments.class=com.benchmark.BaselineProfileGenerator -DBUILD_VARIANT=release

这就是结果

> Task :macro-benchmark:pixel2Api31ReleaseAndroidTest FAILED
Exception thrown during onBeforeAll invocation of plugin com.google.testing.platform.plugin.android.AndroidDevicePlugin.
Failed to install APK: /Users/surajvaishnav/AndroidStudioProjects/MyProject/app/build/outputs/apk/release/app-release-d70a.apk, with option -r,-t
com.google.testing.platform.api.plugin.PluginException: Failed to install APK: /Users/surajvaishnav/AndroidStudioProjects/MyProject/app/build/outputs/apk/release/app-release-d70a.apk, with option -r,-t
        at com.google.testing.platform.plugin.android.AndroidDevicePlugin.beforeAll(AndroidDevicePlugin.kt:109)
        at com.google.testing.platform.plugin.PluginLifecycle$onBeforeAll$1$2$1.invoke(PluginLifecycle.kt:93)
        at com.google.testing.platform.plugin.PluginLifecycle$onBeforeAll$1$2$1.invoke(PluginLifecycle.kt:92)
        at com.google.testing.platform.plugin.PluginLifecycleKt$invokeOrThrow$1.invoke(PluginLifecycle.kt:213)
        at com.google.testing.platform.plugin.PluginLifecycleKt$invokeOrThrow$1.invoke(PluginLifecycle.kt:212)
        at com.google.testing.platform.core.telemetry.common.noop.NoopDiagnosticsScope.recordEvent(NoopDiagnosticsScope.kt:35)
        at com.google.testing.platform.core.telemetry.TelemetryKt.recordEvent(Telemetry.kt:105)
        at com.google.testing.platform.core.telemetry.TelemetryKt.recordEvent$default(Telemetry.kt:98)
        at com.google.testing.platform.plugin.PluginLifecycleKt.invokeOrThrow(PluginLifecycle.kt:212)
        at com.google.testing.platform.plugin.PluginLifecycleKt.invokeOrThrow$default(PluginLifecycle.kt:205)
        at com.google.testing.platform.plugin.PluginLifecycle$onBeforeAll$1.invoke(PluginLifecycle.kt:92)
        at com.google.testing.platform.plugin.PluginLifecycle$onBeforeAll$1.invoke(PluginLifecycle.kt:88)
        at com.google.testing.platform.core.telemetry.common.noop.NoopDiagnosticsScope.recordEvent(NoopDiagnosticsScope.kt:35)
        at com.google.testing.platform.core.telemetry.TelemetryKt.recordEvent(Telemetry.kt:105)
        at com.google.testing.platform.core.telemetry.TelemetryKt.recordEvent$default(Telemetry.kt:98)
        at com.google.testing.platform.plugin.PluginLifecycle.onBeforeAll(PluginLifecycle.kt:88)
        at com.google.testing.platform.executor.SingleDeviceExecutor$execute$4.invoke(SingleDeviceExecutor.kt:86)
        at com.google.testing.platform.executor.SingleDeviceExecutor$execute$4.invoke(SingleDeviceExecutor.kt:86)
        at com.google.testing.platform.executor.SingleDeviceExecutor.runUnlessCancelled(SingleDeviceExecutor.kt:105)
        at com.google.testing.platform.executor.SingleDeviceExecutor.execute(SingleDeviceExecutor.kt:86)
        at com.google.testing.platform.RunnerImpl.run(RunnerImpl.kt:108)
        at com.google.testing.platform.server.strategy.NonInteractiveServerStrategy$run$4.invoke(NonInteractiveServerStrategy.kt:80)
        at com.google.testing.platform.server.strategy.NonInteractiveServerStrategy$run$4.invoke(NonInteractiveServerStrategy.kt:79)
        at com.google.testing.platform.core.telemetry.common.noop.NoopDiagnosticsScope.recordEvent(NoopDiagnosticsScope.kt:35)
        at com.google.testing.platform.core.telemetry.TelemetryKt.recordEvent(Telemetry.kt:66)
        at com.google.testing.platform.server.strategy.NonInteractiveServerStrategy.run(NonInteractiveServerStrategy.kt:79)
        at com.google.testing.platform.main.MainKt$main$4.invokeSuspend(Main.kt:67)
        at kotlin.coroutines.jvm.internal.BaseContinuationImpl.resumeWith(ContinuationImpl.kt:33)
        at kotlinx.coroutines.DispatchedTask.run(DispatchedTask.kt:106)
        at kotlinx.coroutines.EventLoopImplBase.processNextEvent(EventLoop.common.kt:274)
        at kotlinx.coroutines.BlockingCoroutine.joinBlocking(Builders.kt:85)
        at kotlinx.coroutines.BuildersKt__BuildersKt.runBlocking(Builders.kt:59)
        at kotlinx.coroutines.BuildersKt.runBlocking(Unknown Source)
        at kotlinx.coroutines.BuildersKt__BuildersKt.runBlocking$default(Builders.kt:38)
        at kotlinx.coroutines.BuildersKt.runBlocking$default(Unknown Source)
        at com.google.testing.platform.main.MainKt.main(Main.kt:66)
        at com.google.testing.platform.main.MainKt.main$default(Main.kt:34)
        at com.google.testing.platform.main.MainKt.main(Main.kt)
        at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
        at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
        at java.base/java.lang.reflect.Method.invoke(Method.java:566)
        at com.google.testing.platform.launcher.Launcher.main(Launcher.java:149)

下面是测试文件:

@OptIn(ExperimentalBaselineProfilesApi::class)
@RunWith(AndroidJUnit4ClassRunner::class)
class BaselineProfileGenerator {

    @get:Rule
    val rule = BaselineProfileRule()

    @Test
    fun generate() = rule.collectBaselineProfile("com.example.myapp"){
        startActivityAndWait()
    }
}
bqucvtff

bqucvtff1#

好吧,我仍然没有这个问题的答案,但有一个替代方法生成的根设备上的基线配置文件,我已经尝试了模拟器(它可以在真正的根设备太):
1.启用模拟器的根访问权限:
adb根
注:adb根只能与那些没有播放存储在它的模拟器,所以创建一个新的模拟器,如果需要(没有播放存储)。
1.运行此命令:
./gradlew:宏基准测试:已连接基准测试安卓测试-P安卓.测试仪器运行器参数. class = com.包.名称.基线配置文件生成器
在这里,
connectedBenchmarkAndroidTest将使用Benchmark构建类型运行所连接设备的仪器测试,
com.package.name.benchmarkBaselineProfileGenerator是将生成基线配置文件的测试文件的名称。

相关问题