android-plugin
android-plugin copied to clipboard
Skipping ProGuard when using shared Scala libraries
It seems to be possible to set up the emulator with a shared copy of the Scala libraries:
http://lamp.epfl.ch/~michelou/android/emulator-android-sdk.html
When the emulator has been set up in this way, the ProGuard step could be skipped (it's rather slow).
interesting. with the current master you can do:
override def skipProguard = true
to skip the proguard step.
I've noticed proguard still getting executed with this override. I'm quite baffled--looking at the code this should never happen, unless I'm misunderstanding the semantics of "lazy".
you actually need to put the override into both projects (main + test):
trait Defaults extends BaseAndroidProject {
def androidPlatformName = "android-7"
override def skipProguard = true
}
class MainProject(info: ProjectInfo) extends AndroidProject(info) with Defaults { ... }
class TestProject(info: ProjectInfo) extends AndroidTestProject(info) with Defaults
just tried it with a patched emulator image as described above - it works fine, and speeds up the development process considerably. i've mirrored the svn repo with the scripts to generate the patched emulator images: https://github.com/jberkel/android-sdk-scala
here's what i did:
$ git clone git://github.com/jberkel/android-sdk-scala.git && cd android-sdk-scala
$ bin/createdexlibs # predex scala lib
$ bin/createramdisks # patch imgs to include scala in BOOTCLASSPATH
$ emulator -avd ... -ramdisk /path/to/custom.img
$ adb shell mkdir -p /data/framework
$ for i in configs/framework/*.jar; do adb push $i /data/framework/$(basename $i); done
$ adb shell echo '$BOOTCLASSPATH'
/system/framework/core.jar:/system/framework/ext.jar:/system/framework/framework.jar:/system/framework/android.policy.jar:/system/framework/services.jar:/data/framework/scala-library.jar:/data/framework/scala-collection.jar:/data/framework/scala-immutable.jar:/data/framework/scala-mutable.jar:/data/framework/scala-actors.jar
then after rebooting the emulator you can install scala apks on the emulator.
i'd like to make the steps needed to get the emulator to accept scala apks simpler - maybe we could add an sbt task for it ?
quick benchmark (hello world project generated by g8, main apk + tests) with proguard:
$ time sbt clean package-debug
real 0m40.514s
user 0m50.632s
sys 0m2.345s
without proguard:
$ time sbt clean package-debug
real 0m16.507s
user 0m22.199s
sys 0m1.873s
woot!
I pre-packaged the Scala libs for Android so that, after installing, you can reference them in your AndroidManifest.xml with
nice one jrudolph
I got here after asking this question: http://stackoverflow.com/questions/7941178/long-build-times-with-sbt-android-plugin
I will use scala in my application for a small part. I was thinking of trying to package that code in some kind of library to avoid the compile time.
Anyone tried something like that?