Method references are not taken into account by proguard
See original GitHub issueI’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:
- Created 8 years ago
- Comments:13 (5 by maintainers)
Top 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 >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
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.
Ignoring these warnings is enough to fix it: