Skip to content

Instantly share code, notes, and snippets.

View rayshih's full-sized avatar

Ray Shih rayshih

View GitHub Profile
buildscript {
dependencies {
classpath 'com.android.tools.build:gradle:1.2.3'
classpath 'jp.leafytree.gradle:gradle-android-scala-plugin:1.4'
}
}
// 在最上面加入 apply plugin
apply plugin: "com.android.application"
apply plugin:"jp.leafytree.android-scala"
compile 'org.scala-lang:scala-library:2.11.7'
package com.example.rayshih.scala_example
import android.app.Activity
import android.os.Bundle
import android.widget.TextView
class MainActivity extends Activity {
override def onCreate(savedInstanceState: Bundle): Unit = {
super.onCreate(savedInstanceState)
buildTypes {
debug {
minifyEnabled true
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
release {
minifyEnabled true
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
-dontoptimize
-dontobfuscate
-dontpreverify
-dontwarn scala.**
-ignorewarnings
# temporary workaround; see Scala issue SI-5397
-keep class scala.collection.SeqLike {
public protected *;
}
android {
defaultConfig {
// other setting
// minSdkVersion 15 // 這行要拿掉
multiDexEnabled true // 設定啟動 multidex
}
productFlavors {
dev {
minSdkVersion 21 // only apply after android 5.0
<application
android:name="android.support.multidex.MultiDexApplication">
// other config
</application>
package com.rayshih.scala_example
import android.app.Application
import android.content.Context
import android.support.multidex.MultiDex
class MyApp extends Application {
// add this
override protected def attachBaseContext(base: Context) = {
'use strict';
const m = -2;
function prepare(n) {
let b = 1;
let min = 0;
let max = 1;
const bs = [1];