سؤال

Attempting to run a Kotlin Android project using Android Studio compiles successfully and generates an APK, but when Studio tries to install the APK on the device the installation fails with INSTALL_FAILED_DEXOPT. Looking through logcat I can 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 Kotlin IDEA plugin's automatic conversion. There are no compiler warnings.

هل كانت مفيدة؟

المحلول

This occurs when a method name collides with a Kotlin-generated etter, for example:

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

Rename bar or getBar to something else. For more information see http://youtrack.jetbrains.com/issue/KT-3170

نصائح أخرى

Recently the similar issue has been discovered on devices running api 17- with Kotlin 1.0.0-beta-1038.

To fix this issue use new beta build 1.0.0-beta-1103.

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

مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top