Yarikx/reductor

java.lang.NoSuchMethodError: No virtual method

wjs9715 opened this issue · 8 comments

Hello, now I am using reductor for the android project.

For the Store, I had no problem subscribing and canceling the subscription with the retrolambda, but when I use the java 8 lambda expression, I get a following error when I try to cancel the subscription.

java.lang.NoSuchMethodError: No virtual method com_yheriatovych_reductor_Store$$Lambda$2_lambda$subscribe$0(Lcom/yheriatovych/reductor/StateChangeListener;)V in class Lcom/yheriatovych/reductor/Store; or its super classes (declaration of 'com.yheriatovych.reductor.Store' appears in /data/app/com.queuehop.deserteagle-1/base.apk) at com.yheriatovych.reductor.Store$$Lambda$2.cancel(Unknown Source)
Is reductor not compatible with the java's lamda statement?

@Yarikx Same issue

Wow, that's surprising. It's actually compiled with retrolambda into a single jar, but if it creates such problems I might just undo all the lambdas in the code.

@wjs9715 @SaeedMasoumi Is it happening only in proguarded builds?

Java.lang.NoSuchMethodError: No static method lambda$create$0(Lcom/yheriatovych/reductor/Dispatcher;
Lio/reactivex/subjects/PublishSubject;Ljava/lang/Object;)V in class Lcom/yheriatovych/reductor/observable/rxjava2/EpicMiddleware; 
or its super classes (declaration of 'com.yheriatovych.reductor.observable.rxjava2.EpicMiddleware' appears in 
                                                     at com.yheriatovych.reductor.observable.rxjava2.EpicMiddleware$$Lambda$4.dispatch(Unknown Source)

Using Android Studio 3.0 with java 8, debug build

Adding latest retrolambda 'me.tatarka:gradle-retrolambda:3.6.1' solve the problem, but... AS giving nice error:

Warning:One of the plugins you are using supports Java 8 language features. To try the support built into the Android plugin, remove the following from your build.gradle:
    apply plugin: 'me.tatarka.retrolambda'
To learn more, go to https://d.android.com/r/tools/java-8-support-message.html

@wjs9715 No it happened in both proguarded and non-proguarded builds

@Yarikx Any update?

Ok, I found how to reproduce it. It indeed happens for some lambdas ONLY with new Android Java 8 desugaring.
Seems like Google desugar also process libraries and change some methods (even though the library has Java 6 bytecode).

Looks more like a bug in Google tool (as it's still alpha version), I'll investigate it a bit more for now. In the worst case, I'll just unwrap all the lambdas, but I hope I'll find a better way.

As a workaround, you can still disable new Java 8 desugaring and enable retrolambda instead.

FWIW, this is a bug in the Gradle Java 8 language feature desugaring that is tracked in https://issuetracker.google.com/issues/62456849