question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Method references are not taken into account by proguard

See original GitHub issue

I’m not sure whether it’s an issue of retrolambda itself or gradle-retrolambda

Background

Proguard seems to shrink methods, referenced as method references. See an example below:

public class AsyncTaskBuilder<Progress, Result> {

    public interface BackgroundWorkWithProgress<_Progress, _Result> {
        _Result execute(ProgressObserver<_Progress> progressObserver);
    }

    private BackgroundWorkWithProgress<Progress, Result> work;

    public AsyncTask<Void, Progress, Result> build() {

        return new AsyncTask<Void, Progress, Result>() {
            @Override
            protected Result doInBackground(Void... voids) {
                // this reference will not be taken into account by Proguard
                return work.execute(this::publishProgress);
            }

        };
    }
}

After building, the following error is shown:

:app:proguardRelease
Warning: com.github.retrolambda_methodref_repro.AsyncTaskBuilder$1$$Lambda$1: can't find referenced method 'void publishProgress(java.lang.Object[])' in library class android.os.AsyncTask
Warning: there were 1 unresolved references to library class members.
         You probably need to update the library versions.
         (http://proguard.sourceforge.net/manual/troubleshooting.html#unresolvedlibraryclassmember)
Exception while processing task 
java.io.IOException: Please correct the above warnings first.
    at proguard.Initializer.execute(Initializer.java:473)
    at proguard.ProGuard.initialize(ProGuard.java:233)
    at proguard.ProGuard.execute(ProGuard.java:98)
    at proguard.gradle.ProGuardTask.proguard(ProGuardTask.java:1074)
    at com.android.build.gradle.tasks.AndroidProGuardTask.doMinification(AndroidProGuardTask.java:139)
    at com.android.build.gradle.tasks.AndroidProGuardTask$1.run(AndroidProGuardTask.java:115)
    at com.android.builder.tasks.Job.runTask(Job.java:48)
    at com.android.build.gradle.tasks.SimpleWorkQueue$EmptyThreadContext.runTask(SimpleWorkQueue.java:41)
    at com.android.builder.tasks.WorkQueue.run(WorkQueue.java:227)
    at java.lang.Thread.run(Thread.java:745)

Full log is available at travis-ci

Sample android project

Simple android project (with 1 class), reproducing the issue can be found here: https://github.com/denis-itskovich/retrolambda-method-ref-repro

Related issues

The issue seems to be related to this retrolambda issue: https://github.com/orfjackal/retrolambda/issues/48

Issue Analytics

  • State:closed
  • Created 8 years ago
  • Comments:13 (5 by maintainers)

github_iconTop GitHub Comments

1reaction
sunny-chungcommented, Jan 26, 2017

Reproducible in an Android project with gradle-retrolambda 3.2.5 + retrolambda 2.3.0/2.4.0/2.5.0 gradle-retrolambda 3.5.0 + retrolambda 2.5.0,

apply plugin: ‘me.tatarka.retrolambda’ is put at the last.

This plugin was working at past time.

0reactions
ncrucescommented, Apr 13, 2017

Ignoring these warnings is enough to fix it:

-dontwarn **$$Lambda$*
Read more comments on GitHub >

github_iconTop Results From Across the Web

how to fix proguard warning 'can't find referenced method' for ...
I already verified that android-7 supports finalize() and clone() : "...\Android...\sdk\platforms\android-7\android.jar" has methods finalize() and clone() in ...
Read more >
ProGuard Manual: Troubleshooting - Guardsquare
If the package name of some class is missing, ProGuard won't match the elements that you might be expecting. It may help to...
Read more >
Troubleshooting ProGuard issues on Android - Medium
In some cases ProGuard can't know that a class or method is being used, such as when it's only referenced by reflection, from...
Read more >
Android's Built-in ProGuard Rules: The Missing Guide
getDefaultProguardFile() is a simple helper method that fetches them out of build/intermediates/proguard-files . The Android Gradle Plugin (AGP) ...
Read more >
ProGuard Configuration File Translation Tutorial
However, ProGuard has only limited features. For example, it does not provide Flow Obfuscation, Exception Obfuscation, Reference Obfuscation, AutoReflection™, ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found