I want to use both evant/gradle-retrolambda and RoboBinding/RoboBinding in my android project.
When adding RoboBinding to your project, you can choose to use it with AspectJ using RoboBinding/RoboBinding-aspectj-plugin. However, whenever I turn it on, the lambda expressions in my code produce this compile error:
Error:error at (no source information available)
/mnt/FCEE58DAEE588F30/AndroidstudioProjects/SpeechACall/app/src/main/java/com/voicesense/personality_profiling_dialer/GcmRegistrationHandler.java:1:0::0 The type java.lang.invoke.MethodHandles cannot be resolved. It is indirectly referenced from required .class files
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':app:compileDebugAspectJ'.
> The type java.lang.invoke.MethodHandles cannot be resolved. It is indirectly referenced from required .class files
* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.
This is my build.gradle
file
buildscript {
repositories {
mavenCentral()
maven() {
name 'RoboBinding AspectJPlugin Maven Repository'
url "https://github.com/RoboBinding/RoboBinding-aspectj-plugin/raw/master/mavenRepo"
}
}
dependencies {
classpath 'me.tatarka:gradle-retrolambda:2.4.1'
classpath 'com.neenbedankt.gradle.plugins:android-apt:1.+'
classpath 'org.robobinding:aspectj-plugin:0.8.+'
}
}
repositories {
mavenCentral()
}
apply plugin: 'retrolambda'
apply plugin: 'com.android.application'
apply plugin: 'com.neenbedankt.android-apt'
apply plugin: 'org.robobinding.android-aspectj'
android {
compileSdkVersion 21
buildToolsVersion "21.1.1"
defaultConfig {
applicationId "com.voicesense.hr_dialer"
minSdkVersion 15
targetSdkVersion 21
}
signingConfigs {
release {
storeFile file("../../../../../../home/amitai/personality-profiling-dialer_key.keystore")
storePassword System.getenv("KSTOREPWD")
keyAlias "alias_name"
keyPassword System.getenv("KEYPWD")
}
}
buildTypes {
release {
minifyEnabled true
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-project.txt'
signingConfig signingConfigs.release
}
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
}
retrolambda {
jvmArgs '-noverify'
}
ext {
//robobindingVersion = 'latest.integration'
robobindingVersion = '0.8.9'
}
dependencies {
compile files('libs/acra-4.5.0.jar')
compile files('libs/ksoap2-android-assembly-3.0.0-jar-with-dependencies.jar')
compile 'com.google.android.gms:play-services:6.1.71'
compile 'com.android.support:support-v4:21.0.3'
compile 'com.android.support:support-v13:20.0.0'
//compile 'com.netflix.rxjava:rxjava-android:0.20.7'
compile 'io.reactivex:rxandroid:0.24.0'
//compile 'com.googlecode.libphonenumber:geocoder:2.16'
compile 'com.googlecode.libphonenumber:libphonenumber:7.0'
compile ("org.robobinding:robobinding:$robobindingVersion:with-aop-and-dependencies") {
exclude group: 'com.google.guava', module: 'guava'
}
aspectPath ("org.robobinding:robobinding:$robobindingVersion:with-aop-and-dependencies") {
exclude group: 'com.google.guava', module: 'guava'
}
apt "org.robobinding:codegen:$robobindingVersion"
}
And here is a zipped Android Studio project that can be used to reproduce (contains a relevant build.gradle
file and a lambda expression that fails to compile).
After some investigation I found out it had to do with AspectJ not being compatible with Java 8. I believe Java 8 Compatiblity/Update AspectJ · Issue #22 · JakeWharton/hugo and Java 8 not supported · Issue #6 · uPhyca/gradle-android-aspectj-plugin have the same issue. Any suggestions?
I made my own plugin supports aspectj with retrolambda. GradleAndroidAspectJPlugin
When the project is using retrolambda. You have to recompile the classes using ant iajc after retrolamda compiled.