32

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();
}
Lovis
  • 9,513
  • 5
  • 31
  • 47

2 Answers2

48

For anyone in year 2020 and beyond looking for the solution -- Android 11 has the following setting in the Developer options:

enter image description here

It's ON by default. Turn it OFF to get rid of the annoying delays every time app is launched when debugging.

user4698855
  • 2,877
  • 2
  • 16
  • 9
  • And reinstall an application. – CoolMind Feb 19 '21 at 13:24
  • this answer should be marked as the accepted. – erik.aortiz Jan 17 '23 at 17:43
  • I upvoted before trying - turns out this solution for my app leads to an instant native crash after splash screen with message "null pointer dereference". Better not mark this as accepted. Can only run the app in debugger with the verify flag enabled. – 0101100101 Aug 02 '23 at 01:29
11

It looks like this is part of the 'backwards compatibility' requirement for the newer ART runtime. That is, apps built against DALVIK need to be able to run on ART as well.

If you run a DVM app on an ART system, you'll see this message the first time it runs when dex2oat converts the application. If you build the application targeting ART, the app will no longer be able to run on DVM, but the OAT conversion will happen during installation and is not seen at runtime.

Source: The Art of Art note this is part one of a three part investigation of ART and you may need to check parts two and three

David O'Meara
  • 2,983
  • 25
  • 38
  • 7
    I am seeing this message *every time* the app runs, not just the first time. I see the message, kill the app, start it again, and see the message again. – zyamys Jan 16 '17 at 23:24
  • 1
    Did you happen to ever find a resolution for this? I'm getting this when running an android app using bazel. It doesn't happen when I build the same project using gradle. – Jason G Nov 06 '18 at 18:33
  • It's just a warning. Annoying but not an issue. – David O'Meara Nov 08 '18 at 04:48
  • 5
    In my case verification of one of my methods took 900+ ms - it's an issue, when you need to show your app asap. – v1k Jul 08 '20 at 20:17
  • @David O'Meara It's not just a warning. This useless verification takes a lot of time. Annoyance IS an issue. – The incredible Jan Feb 24 '23 at 08:45