We have a fairly large android project all written in kotlin.

When moving from Kotlin 0.6.1315 to 0.6.1411, we get an error when trying to install the generated apk:

12-02 08:46:52.668   2765-2765/? E/dalvikvm﹕ Out-of-order method_idx: 0x1ba9 then 0x1ba9
12-02 08:46:52.668   2765-2765/? E/dalvikvm﹕ Trouble with item 652 @ offset 0x166c34
12-02 08:46:52.668   2765-2765/? E/dalvikvm﹕ Swap of section type 2006 failed
12-02 08:46:52.668   2765-2765/? E/dalvikvm﹕ ERROR: Byte swap + verify failed
12-02 08:46:52.678   2765-2765/? E/dalvikvm﹕ Optimization failed

It looks like the byte code generated by this new version of Kotlin has changed and includes
something that dex doesn’t like.

We’ve had this error before, but it was introduced by changes in our code so we could track it down
to a specific commit and isolate the troubling code. Usually it was because of having a property called
prop when there was already an inherit method called getProp() or setProp() somewhere in the class

This time however, the error is introduced by a change in kotlin version, so we can’t track what’s the
specific code that is causing the problem. Our project is just too large.

I will try to track to narrow the search to the specific version of kotlin where the version starts.

Could you show us the code so that we can reproduce the problem?

This is a large project with multiple modules and I can't tell where the problem comes from because the error message only comes when installing the final apk. I am not sure sending you megabytes of code would be much help. I'll try to figure out exactly what version of kotlin introduced the problem and that should help pinpoint what change in kotlin introduced the problem. If that's not enough, then we'll see if there's something I can send to help track it down further.

Another thing that could help: you mentioned that similar messages arose after some changes in your code. If you could tell us what those changes were, it might be a clue as well. Thanks.

Oh, sorry, you mentioned what the problem was above.

If the cause is the same (i.e. Kotlin now generates some clashing methods), we sould find it by simply reading the binaries of your project (i.e. class files)

The problem is already there with 0.6.1344.

I would have liked to try 1320, 1329, 1336 and 1338 but the “View” dropdown that I use to download old builds on the build server page is missing for those ones.
Is there another place where I could get those builds?

Unfortunately, the older builds are gone, for the buildserver only stores artifacts of so many builds. Could you try 1287 (it has been manually pinned and will now be kept forever)?

Sure, but I expect it will work since 1315 (from maven) does work.

1287 -> works 1315 (maven) -> works 1344 -> doesn't work 1364 -> doesn't work 1381 -> doesn't work 1411 (maven) -> doesn't work 1507 (maven) -> doesn't work

I suspect that the error is introduced in 1320, will try to build it again.

Could you check this build?

(it’s built from sources identical to 1320)


I am getting the error with this build.

Ok, thanks, now we know what functionality is causing the problem, but we do not know how.

We will experiment a little, and you can help us by

  • checking if classes org.jetbrains.annotations.Nullable and org.jetbrains.annotations.NotNull are present in the apk that fails to install.
  • sharing your binaries with us (we can do it privately)

Thanks a lot for your help!

Yes, NotNull.class and Nullable.class are both in there. Please send me information on how I can share the jar privately at contact at jdavid dot info Thank you.