Android + Scala + Intellij 13
android, intellij-idea, scala
Solution
Yes they can.
Prerequisites: Scala SDK installed. Scala Intellij plugin installed. Android Intellij plugins enabled.
No SBT and third party plugins needed. No Gradle. Gradle support is not yet compatible with Scala plugin. Inform me if it is.
- Create new project: In Intellij > New project > Android : Application module > ...Name project, Select API level, Create MyActivity as suggested > Finish
- Create Scala Library: Open Project Structure > Platform Settings > Global Libraries > New Global Library > Java > Browse Scala SDK /lib > Select scala-library.jar [Optionally add link to docs and sources]
- Create Scala Compiler Library: Open Project Structure > New Global Library > Java > Browse Scala SDK /lib > Select scala-library.jar, scala-compiler.jar, scala-reflect.jar
- Add Scala to project module: Open Project Structure > Modules > Expand [your main module] > + Add > Scala > Select "Compiler library" previously added (should be listed in drop down list)
- Add Scala Library to project Module: Open Project Structure > Modules > Select [your module] : Dependencies > + Add > Library > Select "Scala-lib" (previously added to Global libraries)
- Add proguard (lately discovered that Proguard is not required for testing anymore): Add the following to your proguard-project.txt > Scala Proguard. Open Project Structure > Modules > Expand [your main module] > Android : Proguard > Enable "Run Proguard" > Add your proguard-project.txt (having default Android SDK android-proguard.txt)
- Create Scala Activity class: (Note: You already have the Java version of MyActivity created by template: /src/[your_package]/[MyActivity.class]). Right click /src/[your_package] > New > Scala class > Name it [MyActivity] > Ok. Copy all code from java MyActivity.class into newly created MyActivity.scala > Intellij suggests to "Convert code from Java" > Ok. Now you have fully functional MyActivity.scala. Remove java MyActivity.class (without safe delete option) > Check AndroidManifest.xml still linked to MyActivity.
- Enjoy: Run you app in emulator or device. If something goes wrong (as usual) please review your steps. Than think yourself. Than ask help.
Problem
Android is great platform. Scala is great language. Intellij Idea is great IDE. How all of them can work together? Note: It's a self answer. But if you have more info, please share it here.