ART:method() 的验证耗时 X 毫秒 - 需要几分钟

das*_*ima 5 android dalvik android-testing android-runtime

最近,当我尝试调试 android 测试仪器 APK 时,每次启动应用程序时,我都会在 logcat 中看到类似的内容

W/com.myapp: Verification of void com.myapp.test.hiptest.Actionwords.function0() took 158.211ms
W/com.myapp: Verification of void com.myapp.test.hiptest.Actionwords.function1() took 101.701ms
W/com.myapp: Verification of void com.myapp.test.hiptest.Actionwords.function2() took 110.852ms
W/com.myapp: Verification of void com.myapp.test.hiptest.Actionwords.function3() took 211.494ms
W/com.myapp: Verification of void com.myapp.test.hiptest.Actionwords.function4() took 102.497ms
W/com.myapp: Verification of void com.myapp.test.hiptest.Actionwords.function5() took 126.639ms
W/com.myapp: Verification of void com.myapp.test.hiptest.Actionwords.function6() took 138.077ms
W/com.myapp: Verification of void com.myapp.test.hiptest.Actionwords.function7() took 131.311ms
W/com.myapp: Verification of void com.myapp.test.hiptest.Actionwords.function8() took 253.859ms
W/com.myapp: Verification of void com.myapp.test.hiptest.Actionwords.function9() took 111.431ms
W/com.myapp: Verification of void com.myapp.test.hiptest.Actionwords.function10() took 231.172ms
Run Code Online (Sandbox Code Playgroud)

但是有更多的行(对于所有功能)。每个功能需要 100-300 毫秒,当它们全部完成时 - 大约 5-10 分钟过去了。(这意味着我实际上在这 10 分钟内无法做任何事情)

一些谷歌搜索让我找到了这个 SO thread,它解释了以下内容:

看起来这是较新的 ART 运行时的“向后兼容性”要求的一部分。也就是说,针对 DALVIK 构建的应用程序也需要能够在 ART 上运行。

如果您在 ART 系统上运行 DVM 应用程序,当 dex2oat 转换应用程序时,您会在它第一次运行时看到此消息。如果您构建面向 ART 的应用程序,该应用程序将不再能够在 DVM 上运行,但 OAT 转换将在安装期间发生并且在运行时看不到。

但是,我不确定我做错了什么。应用程序和测试 APK 均使用 targetSdk 27​​ 和 minSdk 21 编译。(并在 sdk 27​​ 上运行应用程序)

这个其他 SO 线程似乎也与我遇到的类似,但没有提供答案。

重要提示:这仅适用于通过“调试”工具栏图标运行的构建,而不适用于通过单击“运行”运行的构建。