Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Long build times with sbt android-plugin

I have created a demo application with the sbt android-plugin.

The app is very simple. I have placed a MainActivity.java file under /src/main/java/my/package/ and when a button is pressed it takes you to a second Activity but done in Scala.

Everything is working fine but the build times are killing me. When I modify something I run in my device using:

> android:package-debug

> android:start-device

My issue is that it takes almost a complete minute to build a two activities project. Is there another way to compile and run?

This is my output of android:package-debug

> android:package-debug [info] Wrote /Users/macarse/Documents/demo/target/src_managed/main/scala/my/package/TR.scala [info] Compiling 1 Scala source to /Users/macarse/Documents/demo/target/scala-2.9.0-1/classes... ProGuard, version 4.6 ProGuard is released under the GNU General Public License. You therefore must ensure that programs that link to it (scala, ...) carry the GNU General Public License as well. Alternatively, you can apply for an exception with the author of ProGuard. Reading program directory [/Users/macarse/Documents/demo/target/scala-2.9.0-1/classes] Reading program jar [/Users/macarse/.sbt/boot/scala-2.9.0-1/lib/scala-library.jar] (filtered) Reading library jar [/Users/macarse/Documents/android-sdk-mac_86/platforms/android-4/android.jar] Note: You're ignoring all warnings! Preparing output jar [/Users/macarse/Documents/demo/target/classes.min.jar] Copying resources from program directory [/Users/macarse/Documents/demo/target/scala-2.9.0-1/classes] Copying resources from program jar [/Users/macarse/.sbt/boot/scala-2.9.0-1/lib/scala-library.jar] (filtered) [info] Dexing /Users/macarse/Documents/demo/target/classes.dex [info] Packaging /Users/macarse/Documents/demo/target/demo-0.1.apk [success] Total time: 56 s, completed Oct 29, 2011 4:22:54 PM

like image 783
Macarse Avatar asked Oct 29 '11 19:10

Macarse


2 Answers

There are a couple of options:

  • preinstall scala on the phone/emulator
  • Include predexed scala as a library

There is also a project called treeshaker for Eclipse which is a lot faster than proguard, but it is not integrated w/ the sbt plugin yet.

like image 77
Jan Berkel Avatar answered Oct 14 '22 05:10

Jan Berkel


It takes long time because proguard need to process Scala standard library to minimize the .apk file you get, and Scala standard library is huge.

I will suggest you switch to Scala 2.8 if you didn't use features of Scala 2.9, because 2.8 has a smaller standard library.

In the other hand, don't use android:package-debug when not necessary. compile will compile your source code, it is sufficient if you only want to make sure your program could be compiled.

Only use android:package-debug when you are about to test it on the Android device, this will save your time.

like image 41
Brian Hsu Avatar answered Oct 14 '22 04:10

Brian Hsu