DexGuard 7和Retrofit 2错误

时间:2016-08-24 13:10:08

标签: android obfuscation retrofit2 dexguard

在我的应用中,我使用改造2进行网络通信。 我有一个serverAPI接口,其中包含每个api请求,例如:

@Multipart
@POST(V2__ACCOUNT__UPLOAD_AVATAR)
Call<UploadAvatarResponse> uploadAvatar(@PartMap Map<String, RequestBody> params);

我使用Dexguard 7.2.09对我的应用程序进行模糊处理,并且每个网络通信都在工作,期待一个!

我真的不知道出了什么问题。

我在调试器中看到,当应用程序调用此请求时,代码会跳转到onFailure()方法,但应用程序不会将请求发送到服务器。

如果我不对应用程序进行模糊处理,一切正常。

2 个答案:

答案 0 :(得分:0)

在使用回调时,您可能需要添加以下内容:

-keepattributes Exceptions

答案 1 :(得分:0)

如果您在项目中使用Proguard,请在配置中添加以下行:

# Platform calls Class.forName on types which do not exist on Android to determine platform.
-dontnote retrofit2.Platform
# Platform used when running on RoboVM on iOS. Will not be used at runtime.
-dontnote retrofit2.Platform$IOS$MainThreadExecutor
# Platform used when running on Java 8 VMs. Will not be used at runtime.
-dontwarn retrofit2.Platform$Java8
# Retain generic type information for use by reflection by converters and adapters.
-keepattributes Signature
# Retain declared checked exceptions for use by a Proxy instance.
-keepattributes Exceptions

来源:http://square.github.io/retrofit/