install_failed_dexopt


#1

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:
Failure [INSTALL_FAILED_DEXOPT]

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
hierarchy.

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.


#2

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


#3

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.


#4

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.


#5

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)


#6

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?


#7

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)?


#8

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


#9

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


#10

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


#11

Could you check this build?

http://teamcity.jetbrains.com/viewLog.html?buildId=105146&buildTypeId=bt345&tab=artifacts

(it’s built from sources identical to 1320)

Thanks


#12

I am getting the error with this build.


#13

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!


#14

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.