Installing a Kotlin Android project fails with INSTALL_FAILED_DEXOPT

Attempting to launch an Android Kotlin project using Android Studio successfully compiles and generates an APK, but when Studio tries to install the APK on the device, the installation will complete with INSTALL_FAILED_DEXOPT. Looking through logcat, I see messages similar to:

12-13 22:43:57.219: ERROR/dalvikvm(1623): Out-of-order method_idx: 0x2bff then 0x2bff
12-13 22:43:57.219: ERROR/dalvikvm(1623): Trouble with item 897 @ offset 0x13e498
12-13 22:43:57.219: ERROR/dalvikvm(1623): Swap of section type 2006 failed
12-13 22:43:57.219: ERROR/dalvikvm(1623): ERROR: Byte swap + verify failed
12-13 22:43:57.230: ERROR/dalvikvm(1623): Optimization failed

The project was converted from Java using the automatic conversion of the Kotlin IDEA plugin. There are no compiler warnings.

+3
source share
2 answers

This happens when the method name encounters a thet created by Kotlin, for example:

class Foo(val bar: Any) {
  fun getBar(): Any {}
}

bar getBar . . http://youtrack.jetbrains.com/issue/KT-3170

+6

, api 17- Kotlin 1.0.0-beta-1038.

, - 1.0.0-beta-1103.

https://devnet.jetbrains.com/message/5561799#5561799

0

All Articles