I'm having some issues getting RxAndroid and Google Play Services running together or even build the project in Android Studio after adding Google Play Services. I've used the following 2 helpful sites as references: How to setup retrolambda and Functional Reactive Programming with RxJava in Android. Now maybe I missed something, but I've had issues with java.exe (java 8) either aborting during the build with an exit error or issues with java 8 when running the actual application. From the errors I deduced that I needed retrolambda and there were still issues building my project.
Asked
Active
Viewed 168 times
1 Answers
0
After some trial and error, research, etc. Here's what I found that worked for me. Please note that some of the commented out values at the end of a line were values that I had tried previously.
Project build.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.2.3' //1.3.0
classpath 'me.tatarka:gradle-retrolambda:3.2.0' //2.5.0
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
// jcenter()
mavenCentral()
}
}
Module build.gradle
apply plugin: 'com.android.application'
apply plugin: 'me.tatarka.retrolambda'
android {
compileSdkVersion 22 //21
buildToolsVersion "21.1.2" //21.1.2
defaultConfig {
applicationId "com.your.app"
minSdkVersion 18
targetSdkVersion 22 //21
multiDexEnabled = true
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
dexOptions {
javaMaxHeapSize "2g"
preDexLibraries = true //false
incremental false
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.android.support:appcompat-v7:22.2.1' //21.0.3 22.2.1
compile 'com.google.android.gms:play-services:7.8.0' //7.8.0
compile 'io.reactivex:rxandroid:0.24.0'
}
retrolambda {
jvmArgs '-noverify'
jdk System.getenv("JAVA8_HOME")
oldJdk System.getenv("JAVA7_HOME")
javaVersion JavaVersion.VERSION_1_7
defaultMethods false
incremental true
}
proguard-rules.pro
-dontwarn java.lang.invoke.*
In addition, I added the above referenced path environment values JAVA7_HOME, JAVA8_HOME which point to the appropriate directory for each java install.

Peter Birdsall
- 3,159
- 5
- 31
- 48