Is there any specific steps to run Kotlin on Android device?


#1

My app runs properly in emulator, however when I try to run in on a 2.2 device, it throws up this error

11-22 16:25:24.320: ERROR/AndroidRuntime(11518): FATAL EXCEPTION: main   java.lang.NoSuchMethodError: java.util.Arrays.copyOf   at kotlin.namespace$src$ArraysJVM$2089253253.copyOf(ArraysJVM.kt:88)   at kotlin.namespace.copyOf(DoubleArraysFromIterablesJVM.kt:1)   at kotlin.ImmutableArrayListBuilder.ensureCapacity(ImmutableArrayList.kt:85)   at kotlin.ImmutableArrayListBuilder.add(ImmutableArrayList.kt:90)   at com.silverkeytech.android_rivers.DownloadSubscription$handleRiversListing$1.invoke(DownloadSubscription.kt:99)   at com.silverkeytech.android_rivers.DownloadSubscription$handleRiversListing$1.invoke(DownloadSubscription.kt)   at kotlin.namespace$src$Iterables$1328673291.forEach(Iterables.kt:136)   at kotlin.namespace.forEach(DoubleArraysFromIterablesJVM.kt:1)   at com.silverkeytech.android_rivers.DownloadSubscription.handleRiversListing(DownloadSubscription.kt:98)   at com.silverkeytech.android_rivers.DownloadSubscription.onPostExecute(DownloadSubscription.kt:90)   at com.silverkeytech.android_rivers.DownloadSubscription.onPostExecute(DownloadSubscription.kt)   at android.os.AsyncTask.finish(AsyncTask.java:417)   at android.os.AsyncTask.access$300(AsyncTask.java:127)   at android.os.AsyncTask$InternalHandler.handleMessage(AsyncTask.java:429)   at android.os.Handler.dispatchMessage(Handler.java:99)   at android.os.Looper.loop(Looper.java:123)   at android.app.ActivityThread.main(ActivityThread.java:4627)   at java.lang.reflect.Method.invokeNative(Native Method)   at java.lang.reflect.Method.invoke(Method.java:521)   at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:858)   at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616)   at dalvik.system.NativeStart.main(Native Method)


#2

I think there's a bug in ImmutableArrayListBuilder

When I changed this code
  var vals = ImmutableArrayListBuilder<FeedItem>()


to
  var vals = ArrayList<FeedItem>()

everything works fine.


#3

Arrays.copyOf() is available since JDK 1.6, seems to me, it's not there on Android. This is not exactly a bug, but an incompatibnility.

Please, report this to the tracker. Thanks


#4

http://youtrack.jetbrains.com/issue/KT-3081