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.
To start working with Scala in IntelliJ IDEA you need to download and enable the Scala plugin. If you run IntelliJ IDEA for the first time, you can install the Scala plugin when IntelliJ IDEA suggests downloading featured plugins. Otherwise, you can use the Settings | Plugins page for the installation.
Open IntelliJ IDEA, go to File Menu --> Plugins --> [ Or directly press Ctrl+Alt+S ] Click on "Browse repositories" button and enter "Scala". Select Scala plugin to install it.
Support for Scala, SBT and Hocon is available for free in IntelliJ IDEA Community Edition, while support for Play Framework and Scala. js is available only in IntelliJ IDEA Ultimate.
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.
I use successfuly Scala 2.11.7 + Android Studio + Gradle with this plugin gradle-android-scala-plugin and current config:
build.gradle
buildscript {
repositories {
jcenter()
mavenCentral()
maven {
url "http://saturday06.github.io/gradle-android-scala-plugin/repository/snapshot"
}
}
dependencies {
classpath 'com.android.tools.build:gradle:1.0.1'
classpath 'jp.leafytree.gradle:gradle-android-scala-plugin:1.3.2'
classpath "org.scala-lang:scala-library:2.11.7"
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
jcenter()
}
}
app/build.gradle
apply plugin: 'com.android.application'
apply plugin: "jp.leafytree.android-scala"
android {
compileSdkVersion 22
buildToolsVersion "19.1.0"
defaultConfig {
applicationId "com.example.adray.myapplication"
minSdkVersion 15
targetSdkVersion 19
versionCode 1
versionName "1.0"
}
lintOptions {
abortOnError false
}
sourceSets {
main {
scala {
srcDir "src/main/scala" // default: "src/main/scala"
}
}
androidTest {
scala {
srcDir "src/androidTest/scala" // default: "src/androidTest/scala"
}
}
}
buildTypes {
release {
minifyEnabled true
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
debug {
minifyEnabled true
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.github.satyan:sugar:1.3'
compile 'org.scala-lang:scala-library:2.11.7'
compile 'com.google.android.gms:play-services:7.5.0'
compile 'com.android.support:appcompat-v7:22.2.0'
}
repositories {
mavenCentral()
jcenter()
}
proguard-rules.pro
-dontoptimize
-dontobfuscate
-dontpreverify
-dontwarn scala.**
-dontwarn android.support.v4.app.**
-dontwarn android.support.v4.view.**
-dontwarn android.support.v4.widget.**
-ignorewarnings
# temporary workaround; see Scala issue SI-5397
-keep class scala.collection.SeqLike {
public protected *;
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With