Fork me on GitHub

Tuesday, April 22, 2014

Android API 8 is incompatible with mutable collections from Scala 2.11

I've found that newly introduced class scala.collection.mutable.AnyRefMap and mutable.LongMap are using java.util.Arrays.copyOf(...), that is available only on Android API level 9 and above. This means that your Android app might not work with Froyo devices if you build it with Scala 2.11. Because the current market share of the API level < 9 is less than 1 percent, this limitation is not serious.

However, if you stick to support older Android devices, here is a workaround:
  • Add -dontwarn scala.collection.mutable.** in your proguard settings.
  • Do not use scala.collection.mutable.LongMap and mutable.AnyRefMap. Make sure these classes not be called in transitive way.

5 comments:

  1. It was my understanding that 2.11 was incompatible with Android because it relied heavily on Java 8?

    https://groups.google.com/forum/#!topic/scala-on-android/KPDzH646C6g

    ReplyDelete
  2. Scala 2.11 is compatible with Java 6.

    http://www.scala-lang.org/news/2014/03/20/release-notes-2.11.0-RC3.html

    ReplyDelete
  3. I really enjoy simply reading all of your weblogs. Simply wanted to inform you that you have people like me who appreciate your work. Definitely a great post I would like to read this
    qlik sense online training

    ReplyDelete
  4. I found this informative and interesting blog so i think so its very useful and knowledge able.I would like to thank you for the efforts you have made in writing this article.

    ReactJS Online Training

    ReplyDelete
  5. Thanks for your informative article, Your post helped me to understand the future and career prospects & Keep on updating your blog with such awesome article.
    Sql server dba online training

    ReplyDelete