天天看點

Mac Android Studio Java8 lambda RxAndroid 配置

apply plugin: 'com.android.application'
apply plugin: 'com.neenbedankt.android-apt'
apply plugin: 'me.tatarka.retrolambda'

android {
    compileSdkVersion 22
    buildToolsVersion "22.0.1"

    defaultConfig {
        multiDexEnabled true
       ...
    }

    retrolambda {
        javaVersion JavaVersion.VERSION_1_7
        jdk "/Library/Java/JavaVirtualMachines/jdk1.8.0_51.jdk/Contents/Home"
        oldJdk "/Library/Java/JavaVirtualMachines/jdk1.7.0_79.jdk/Contents/Home"
    }

    compileOptions {
        sourceCompatibility JavaVersion.VERSION_1_8
        targetCompatibility JavaVersion.VERSION_1_8
    }

}

dependencies {
    compile fileTree(dir: 'libs', include: ['*.jar'])
    compile 'com.android.support:support-v4:22.2.1'
    compile 'com.android.support:cardview-v7:22.2.1'
    compile 'com.android.support:design:22.2.1'
    compile 'com.android.support:recyclerview-v7:22.2.1'
    compile 'com.android.support:appcompat-v7:22.2.1'
    compile 'com.google.code.gson:gson:2.3.1'
    compile 'com.github.bumptech.glide:glide:3.6.0'
    compile 'com.squareup.retrofit:retrofit:1.9.0'
    compile 'com.squareup.okhttp:okhttp-urlconnection:2.0.0'
    compile 'com.squareup.okhttp:okhttp:2.0.0'
    compile 'jp.wasabeef:glide-transformations:[email protected]'
    compile 'jp.co.cyberagent.android.gpuimage:gpuimage-library:[email protected]'
    compile 'com.jakewharton:butterknife:7.0.1'
    compile 'com.google.dagger:dagger:2.0.1'
    compile 'io.reactivex:rxandroid:1.0.1'
    apt 'com.google.dagger:dagger-compiler:2.0.1'
}
           

以上為app gradle,下面為module gradle

// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
    repositories {
        jcenter()
        mavenCentral()
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:1.3.0'
        classpath 'com.neenbedankt.gradle.plugins:android-apt:1.4'
        classpath 'me.tatarka:gradle-retrolambda:3.2.1'
    }
}

allprojects {
    repositories {
        jcenter()
    }
}
           

以下為mac系統裡 ~/.bash_profile

export JAVA7_HOME="$(/usr/libexec/java_home -v 1.7)"
export JAVA8_HOME="$(/usr/libexec/java_home -v 1.8)"
export JAVA_HOME="$(/usr/libexec/java_home -v 1.8)"
           

其他使用方式請參見

大鬼頭 http://blog.csdn.net/lzyzsd/article/details/41833541

RxJava http://blog.csdn.net/job_hesc/article/details/45798307

GitHub RxJava相關彙總 https://github.com/lzyzsd/Awesome-RxJava

RxJava-Android https://github.com/ReactiveX/RxJava/wiki/The-RxJava-Android-Module

Rx-Android 應用架構 https://github.com/tehmou/rx-android-architecture

Java8 簡明教程 http://www.importnew.com/10360.html

RxAndroid http://coderrobin.com/2015/07/17/RxAndroid%E5%88%9D%E6%8E%A2/

繼續閱讀