2016-05-04

讓 Android Studio 2.1 支援 Lambda expression & Stream API & ButterKnife依賴注入框架


要讓 Android Studio 2.1 能支援java 8的Lambda expression & Stream API & ButterKnife依賴注入框架,
請先安裝JDK8,並修改專案gradle設定檔如下:

gradle.build (Project):

buildscript {
    repositories {
        jcenter()
        //加入套件來源maven
        mavenCentral()
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:2.1.0'
        // 加入dependency (gradle-retrolambda 外掛)
        classpath 'me.tatarka:gradle-retrolambda:3.2.5'
        // 加入dependency (android-apt 外掛)
        classpath 'com.neenbedankt.gradle.plugins:android-apt:1.8'
    }
}

repositories {
    //加入maven 
    mavenCentral()
}

allprojects {
    repositories {
        jcenter()
    }
}

task clean(type: Delete) {
    delete rootProject.buildDir
}