Butterknife不支持启用Proguard,使用推荐的proguard规则

时间:2015-11-12 01:55:22

标签: android proguard butterknife

我使用了ButterKnife,在我的发布版本中,它始终会在与NullPointerException相关联的任何视图上抛出@Bind

我已提出推荐设置:

我对黄油刀使用了以下设置:

第一次互动

-keep class butterknife.** { *; }
-dontwarn butterknife.internal.**
-keep class **$$ViewBinder { *; }

-keepclasseswithmembernames class * {
     @butterknife.* <fields>;
}

-keepclasseswithmembernames class * {
    @butterknife.* <methods>;
}

第二次迭代:

# Butterknife
-dontwarn butterknife.internal.**
-keep class **$$ViewInjector { *; }
-keepnames class * { @butterknife.InjectView *;}

亏本,我希望我的代码使用minifyEnabled进行模糊处理,但似乎无法使用ButterKnife

任何时候我关闭minifyEnabled它都可以。

其他人有运气吗?

1 个答案:

答案 0 :(得分:0)

使用最新版的butterknife

http://jakewharton.github.io/butterknife/

编译'com.jakewharton:butterknife:7.0.1'

正如 Jakewharton

所述

请务必在build.gradle中禁止此lint警告。

   lintOptions {
      disable 'InvalidPackage'
   }

某些配置可能还需要其他排除。

   packagingOptions {
     exclude 'META-INF/services/javax.annotation.processing.Processor'
   }

然后尝试我希望它会起作用。

相关问题