Skip to content

Instantly share code, notes, and snippets.

@JeroMiya
Created July 19, 2014 03:14
Show Gist options
  • Star 4 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save JeroMiya/fc81d5c33ef7b8cf395f to your computer and use it in GitHub Desktop.
Save JeroMiya/fc81d5c33ef7b8cf395f to your computer and use it in GitHub Desktop.
Android Studio Scala Gradle config
apply plugin: 'com.android.application'
apply plugin: 'android-scala'
android {
compileSdkVersion 'android-L'
buildToolsVersion "20.0.0"
defaultConfig {
applicationId "com.example.jeremybell.myapplication"
minSdkVersion 15
targetSdkVersion 'L'
versionCode 1
versionName "1.0"
}
sourceSets {
main {
scala {
srcDir "src/main/scala" // default: "src/main/scala"
}
}
androidTest {
scala {
srcDir "src/androidTest/scala" // default: "src/androidTest/scala"
}
}
}
buildTypes {
release {
runProguard true
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
debug {
runProguard true
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'org.scala-lang:scala-library:2.11.1'
}
repositories {
mavenCentral()
}
package com.example.jeremybell.myapplication
import android.app.Activity
import android.os.Bundle
import android.view.Menu
import android.view.MenuItem
class MyActivity extends Activity {
override def onCreate(savedInstanceState: Bundle): Unit = {
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_my)
}
override def onCreateOptionsMenu(menu: Menu): Boolean = {
// Inflate the menu; this adds items to the action bar
// if it is present.
getMenuInflater().inflate(R.menu.my, menu)
true
}
override def onOptionsItemSelected(item: MenuItem): Boolean = {
// Handle action bar item clicks here. The action bar will
// automatically handle clicks on the Home/Up button, so long
// as you specify a parent activity in AndroidManifest.xml
val id = item.getItemId()
if(id == R.id.action_settings) {
true
} else {
super.onOptionsItemSelected(item)
}
}
}
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
repositories {
jcenter()
mavenCentral()
maven {
url "http://saturday06.github.io/gradle-android-scala-plugin/repository/snapshot"
}
}
dependencies {
classpath 'com.android.tools.build:gradle:0.12.+'
classpath 'jp.leafytree.gradle:gradle-android-scala-plugin:1.0-SNAPSHOT'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
jcenter()
}
}
@christopherperry
Copy link

Not working for me unfortunately. Can you give some guidance?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment