26

I've got a warning in my logcat:

W/art: Verification of void com.myapp.LoginFragment$override.lambda$logIn$5(com.myapp.LoginFragment, java.lang.Throwable) took 217.578ms

Here's the code:

subscription = viewModel.logIn()
            .observeOn(AndroidSchedulers.mainThread())
            .subscribe(
               this::showStudioSelection,
               error -> {
                    ErrorResponse errorResponse = ErrorResponseFactory.create(error);

                    if (errorResponse.code() == ApiResult.BAD_REQUEST) {
                       Snackbar.make(getView(), R.string.login_bad_credentials, Snackbar.LENGTH_LONG)
                            .setAction(android.R.string.ok, v -> {})
                            .show();
                    } else {
                        Snackbar.make(getView(), "Unknown error " + errorResponse.code(), Snackbar.LENGTH_LONG)
                            .setAction(android.R.string.ok, v -> {})
                            .show();
                    }
                    viewModel.updateLoginButtonState();
                 }
            );

220ms is quite a lot (and I feel like I'm noticing a lag on startup of that Fragment).

I'm using RxJava and retrolambda, but this is not the only spot where this message pops up so I don't think it's directly related.

How can I influence the verification time? Is it even worth it?

It seems like it has something to do with cyclomatic complexity, since I could get rid of the waring by removing the Snackbar.make calls in the if with some more dry code:

String errorMessage;
if (errorResponse.code() == ApiResult.BAD_REQUEST) {
    errorMessage = getString(R.string.login_bad_credentials);
} else {
    errorMessage = "Unknown error " + errorResponse.code();
}
4

2 回答 2

31

对于 2020 年及以后寻找解决方案的任何人——Android 11 在开发者选项中有以下设置:

在此处输入图像描述

默认开启。在调试时每次启动应用程序时将其关闭以消除烦人的延迟。

于 2020-09-17T04:32:54.243 回答
10

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

如果您在 ART 系统上运行应用程序,您将在转换应用程序DVM时第一次运行时看到此消息。dex2oat如果您构建应用程序目标ART,应用程序将不再能够运行DVM,但OAT转换将在安装过程中发生,并且在运行时看不到。

资料来源:The Art of Art 注意这是对 ART 的三部分调查的第一部分,您可能需要查看第二部分第三部分

于 2016-05-27T04:13:07.307 回答