Search This Blog

Saturday, 4 April 2015

SCALA development for Android is becoming more pragmatic

Only three weeks after my last post SCALA development for Android is becoming more pragmatic again. This is due to the new IntelliJ IDEA version 14.1.. IntelliJ IDEA provides now a seamless integration of the android-sdk-plugin:
  1. Set ANDROID_HOME to the path where you have stored your Android SDK.
  2. Download latest hello scaloid project template.
  3. Go to the root of the hello scaloid project and type:
    android update project -p .
  4. Make sure you use IntelliJ IDEA 14.1 or later.
  5. Install SCALA and Android plugins into IDEA.
  6. File -> New -> Import Project... -> Import project from external sources... -> Import project from external model -> select SBT.
This should do the job and compiling and debugging should work out of the box.

Sunday, 15 March 2015

SCALA development for Android

One year ago, I was excited how easy scala development could be done for Android within Eclipse. I just added the scala-ide plugin for eclipse plus the ANDROID_PROGUARD_SCALA plugin. Everything worked nicely out of the box.
When you search the web today this procedure is still promoted actively in many places such as the official SCALA website. Just try this if you have a few hours to loose. I tried it with the SCALA ide and Eclipse Luna standard edition ....

The next thing I tried was the new SCALA activator tool which looks great and you can find templates for Android and Scaloid. Unfortunately, they seem to be outdated and you should try to use activator for this purpose, only if you have a few hours to loose....

After too many hours lost, this is how it worked out for me:

  1. Start from the hello scaloid project template.
  2. Update the plugins inside /project/plugins.sbt to their last versions.
  3. Set ANDROID_HOME to the path where you have stored your Android SDK.
  4. Start sbt inside the project folder.
  5. You can call "sbt android:package" to compile the project.
    Unfortunately the Proguard settings are not good anymore. I have to look into Proguard settings at  a later time. For now, I set useProguard := false in build.sbt to get started.
  6. "sbt run" puts the apk file on your connected device and runs it. Now you can compile and run the Android command line tools.
  7. Do you want to compile, run and debug from an IDEA? "sbt eclipse" creates you a project. Unfortunately again, this does not work! No easy eclipse integration.
    IntelliJ IDEA comes to a rescue.
  8. Add the sbt-idea plugin to sbt.
  9. Run "sbt gen-idea"
  10. Now you can open your project with IntelliJ and compiling and debugging works fine through the IDEA. 
As a conclusion, it is pretty clear that the pragmatic Android developer is not going to write his code in SCALA.