android-plugin icon indicating copy to clipboard operation
android-plugin copied to clipboard

Skipping ProGuard when using shared Scala libraries

Open liff opened this issue 15 years ago • 7 comments

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).

liff avatar Nov 04 '10 12:11 liff

interesting. with the current master you can do:

override def skipProguard = true

to skip the proguard step.

jberkel avatar Apr 28 '11 17:04 jberkel

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".

appamatto avatar May 05 '11 21:05 appamatto

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

jberkel avatar May 14 '11 09:05 jberkel

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!

jberkel avatar May 14 '11 11:05 jberkel

I pre-packaged the Scala libs for Android so that, after installing, you can reference them in your AndroidManifest.xml with tags for developing purposes. You can find it at jrudolph/scala-android-libs .

jrudolph avatar Jul 23 '11 10:07 jrudolph

nice one jrudolph

charroch avatar Oct 12 '11 16:10 charroch

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?

Macarse avatar Oct 31 '11 13:10 Macarse