内部接口的Proguard配置

时间:2018-05-31 17:10:42

标签: java proguard

我有类实现其他类的实现内部接口,如下所示:

public class DownloadService extends Service implements Downloader.Callback { 
    ....
    // override interface methods and other stuff
    ....
}

public class Downloader {
    private Callback callback;

    public Downloader(Callback callback) {
        this.callback = callback;
    }

    ....
    ....

    public interface Callback {
        // interface methods
    }
}

现在,当我在这段代码上使用proguard时,我收到这样的警告:

com.example.DownloadService$Downloader: can't find referenced method 'java.util.List access$000(com.example.DownloadService)' in program class com.example.DownloadService  
com.example.DownloadService$Downloader: can't find referenced method 'void access$100(com.example.DownloadService)' in program class com.example.DownloadService    
com.example.DownloadService$Downloader: can't find referenced method 'android.app.NotificationManager access$200(com.example.DownloadService)' in program class com.example.DownloadService

我该如何解决这个问题?我尝试将以下内容添加到我的proguard.cfg中:

-keepclasseswithmembers class com.example.DownloadService { *; }
-keep public interface com.example.tasks.Downloader$Callback { *; }

1 个答案:

答案 0 :(得分:1)

我明白了。 com.example.DownloadService$Downloader是我最近删除的内部类。 Build>清洁项目修复它。

我生命中的4个小时 - 刚刚离开。