使用Retrofit 在代码混淆后 提示 Last parameter must be of type Callback or Callback
来源:互联网 发布:小米手机没有4g网络 编辑:程序博客网 时间:2024/06/05 22:58
公司项目要结束了,在准备上线前是要做代码混淆的, 可是混淆后确实能生成APK 包,但是发现打开后联网操作的时候会崩溃掉。
先打开DDMS,找到进程的PID,再用LogCat跟踪这个PID ,来看是什么错误。崩溃后发现提示的错误是
Last parameter must be of type Callback<X> or Callback<? super X>
问题出现在使用Retrofit联网的时候,那么先看看我们有没有把Retrofit用到的文件-Keep住
-dontwarn retrofit.**-keep class retrofit.** { *; }
已经加上了,可是还是会出错,google之~
在github上找到了一篇文章 Retrofit 1.3.0 doesn’t work after obfuscation using ProGuard
这个叫tshevchuk的小哥遇到了跟我一样的问题,看了一下他改过的proguard-project.txt文件,加上了对GSON的-keep,我们也加上,proguard-project.txt文件变成这样
-dontwarn retrofit.**-keep class retrofit.** { *; }-keepattributes Signature-keepattributes Exceptions-dontwarn rx.*-keep class sun.misc.Unsafe { *; }-keep class com.google.gson.examples.android.model.** { *; }
再Relase一遍,OK,可以请求网络了
GSON的混淆可以参考Stackoverflow上的这篇文章Proguard issue while using GSON
0 0
- 使用Retrofit 在代码混淆后 提示 Last parameter must be of type Callback or Callback
- android 使用proguard 代码混淆后,出现异常 Missing type parameter.
- android 使用proguard 代码混淆后,出现异常 Missing type parameter.
- TypeError: super(type, obj): obj must be an instance or subtype of type
- CALLBACK
- callback
- Callback
- CALLBACK
- Callback
- CALLBACK
- CALLBACK
- callBack
- callback
- callback
- callback
- Property with 'retain (or strong)' attribute must be of object type
- Property with 'retain(or strong) attribute must be of object type
- 『IOS』Property with 'retain (or strong)' attribute must be of object type
- shell编程(二):文件操作
- Codeforces Round #340 (Div. 2)C. Watering Flowers(暴力)
- gh60 刷固件
- transaction.addToBackStack(null);无效问题
- 简单的百度定位
- 使用Retrofit 在代码混淆后 提示 Last parameter must be of type Callback or Callback
- QRegExp解析
- [LeetCode] Linked List Cycle 与 Linked List Cycle II
- 近期项目开发中的一些总结
- CRC16校验C语言程序源码
- 蓝桥杯-十六进制转八进制
- myeclipse10 中的UTF-8 设置
- TF-IDF及其算法
- 数据结构(19)--DAG应用之AOE网的拓扑排序