android - 在签名的 apk 中,butterknife 不工作

标签 android apk butterknife

我使用 butterknife 创建了一个应用程序来实现 onclick、ontouch 等功能,当我在我的 android 设备上测试它时它工作正常,当我在 android 设备中安装 debug-apk 时它也工作正常。但是,当我生成一个签名的 apk 并尝试在我的 android 设备上运行它时,“onclick”和“ontouch”不起作用。我使用 Android studio 生成了 apk。有谁知道发生这种情况的原因吗?

最佳答案

复制自http://jakewharton.github.io/butterknife/ 在 proguard-rules.pro 文件中使用这些规则

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

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

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

关于android - 在签名的 apk 中,butterknife 不工作,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35789105/

相关文章:

android - 类中的 TextView 和 setText

Android Studio 1.0.0 - 未能找到 butterknife :6. 0.0

java - 我需要将我的 apk 导入 eclipse - 可能吗?

android - Android 的 UI 自动化测试

java - 安卓 ButterKnife java.lang.NoClassDefFoundError : Failed resolution of: Lbutterknife/ButterKnife

android - 用于手机和平板电脑的不同布局的 Butterknife

android - AsyncTask内存崩溃

android - 插页式 Admob 不起作用 : AFMA_ReceiveMessage is not defined

android - 在没有浏览器的嵌入式设备上使用 google api 访问应用程序中的用户数据

android - 在不安装新 APK 的情况下更新应用程序