Proguard-找不到引用的方法

时间:2018-06-20 11:14:37

标签: android proguard android-proguard

我必须使用com.android.tools.build:gradle:3.1.3将构建工具升级到gradle 4.4。我的项目以前与proguard配合良好。但是升级后,存在很多以下问题:

MainActivity: can't find referenced method 'void setAlpha(float)' in program class android.view.View
...can't find referenced method 'void execute(java.lang.Runnable)' in program class android.os.AsyncTask
...can't find referenced method 'void overridePendingTransition(int,int)'
...can't find referenced method 'boolean canPause()' in program class android.widget.VideoView
Warning: library class android.app.AlarmManager$AlarmClockInfo depends on program class android.os.Parcelable$Creator
Warning: library class android.graphics.drawable.AdaptiveIconDrawable extends or implements program class android.graphics.drawable.Drawable

我在proguard文件中错过了什么?

花了很多时间看日志猫之后,我发现每个referenced method都是Added in API level 11 or above(我正在使用if / else检查),而我的min sdk是{{1 }}。有什么建议吗?

1 个答案:

答案 0 :(得分:1)

Proguard版本已使用buildtools更新,也许这是该Proguard版本的问题。您是否尝试过手动降级(或升级)您的Proguard版本以查看是否仍然出现该错误?

像这样覆盖它

buildscript {
    configurations.all {
        resolutionStrategy {
            force 'net.sf.proguard:proguard-gradle:x.x.x' //here use whatever version you'd like
        }
    }
}

并像这样查找您的proguard版本

./gradlew buildEnvironment