4

I want to use method-references on Android API 23 and am stuck. I tried retrolambda and some other methods but it still doesn't work.

RequestClass.doRequestWithApi(this.getApplicationContext(), this.TAG, dataToPass, this::getMyAccount);

I am using java 8 and compile on sdk 26 (min 23).

Here's the error

E/MultiWindowProxy: getServiceInstance failed!
E/AndroidRuntime: FATAL EXCEPTION: main
                  Process: etsymbiose.defdress, PID: 8296
                  java.lang.NoClassDefFoundError: etsymbiose.defdress.LoginActivity$$Lambda$1
                      at etsymbiose.defdress.LoginActivity.onCreate(LoginActivity.java:51)
                      at android.app.Activity.performCreate(Activity.java:6301)
                      at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1113)
                      at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2519)
                      at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2654)
                      at android.app.ActivityThread.-wrap11(ActivityThread.java)
                      at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1488)
                      at android.os.Handler.dispatchMessage(Handler.java:111)
                      at android.os.Looper.loop(Looper.java:207)
                      at android.app.ActivityThread.main(ActivityThread.java:5728)
                      at java.lang.reflect.Method.invoke(Native Method)
                      at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:789)
                      at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:679)

Is there a way to make this work?

  • Are you using proguard to remove unused code from your project? My recollection is that proguard doesn't "see" `this::getMyAccount` as a reference to the `getMyAccount` method, so it could be deleting it. – Ben P. Jan 08 '18 at 17:40
  • I'm not using proguard so I guess it's something else. However, this code is working on my friend's phone (API 24) – Ulrikat Stern Jan 08 '18 at 18:02
  • 1
    Please post the *exact* error message. – Anlon Burke Jan 09 '18 at 10:27
  • What version of the `Android Gradle Plugin` do you use. Starting with 3.0, `retrolambda` is no longer required: https://developer.android.com/studio/write/java8-support.html – Christopher Jan 09 '18 at 13:28
  • Gradle version 4.1 and Android Plugin Version 3.0.1, but it's not working with or without retrolambda – Ulrikat Stern Jan 09 '18 at 13:40

0 Answers0