Skip to content

Commit e2229a8

Browse files
author
Karl Rieb
committed
Fix ProGuard optimizing of error deserialization code, in particular @JsonCreator annotated constructor.
See bug report here: https://www.dropboxforum.com/hc/en-us/community/posts/205611143-BadResponseException-Bad-JSON Fixes T94429
1 parent 8dabdf4 commit e2229a8

File tree

3 files changed

+17
-4
lines changed

3 files changed

+17
-4
lines changed

ChangeLog.txt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
---------------------------------------------
2+
2.0.3
3+
- Fix Bad JSON error on ProGuard optimized APKs when deserializing error responses.
4+
15
---------------------------------------------
26
2.0.2 (2016-04-28)
37
- Update to latest API specs:

examples/android/build.gradle

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ apply plugin: 'com.android.application'
2323

2424
android {
2525
compileSdkVersion 23
26-
buildToolsVersion "23.0.2"
26+
buildToolsVersion "23.0.3"
2727

2828
defaultConfig {
2929
applicationId "com.dropbox.core.examples.android"
@@ -34,12 +34,14 @@ android {
3434
}
3535
buildTypes {
3636
release {
37-
minifyEnabled false
37+
minifyEnabled true
38+
shrinkResources true
3839
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
3940
}
4041
debug {
4142
// to debug ProGuard rules
4243
minifyEnabled false
44+
shrinkResources false
4345
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
4446
}
4547
}
@@ -57,8 +59,8 @@ dependencies {
5759
compile 'com.android.support:appcompat-v7:23.1.1'
5860
compile 'com.android.support:design:23.1.1'
5961
compile 'com.android.support:recyclerview-v7:23.1.1'
60-
compile 'com.fasterxml.jackson.core:jackson-core:2.5.4'
61-
compile 'com.fasterxml.jackson.core:jackson-annotations:2.5.4'
62+
compile 'com.fasterxml.jackson.core:jackson-core:2.7.1'
63+
compile 'com.fasterxml.jackson.core:jackson-annotations:2.7.1'
6264
compile 'com.squareup.picasso:picasso:2.5.2'
6365
compile 'com.squareup.okhttp:okhttp:2.4.0'
6466
}

src/main/java/com/dropbox/core/DbxRequestUtil.java

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -272,6 +272,13 @@ public static ErrorWrapper fromResponse(Type errType, HttpRequestor.Response res
272272
);
273273
ApiErrorResponse<?> apiResponse = JSON.readValue(response.getBody(), type);
274274

275+
// ProGuard/Dex hack: prevent ProGuard/Dex from optimizing away our @JsonCreator
276+
// constructor. We add this code here instead of updating our rules to allow developers
277+
// to easily fix their broken apps by updating the SDK version (see T94429).
278+
if (errType == null) {
279+
new ApiErrorResponse<Object>("impossible", new LocalizedText("impossible", "en_US"));
280+
}
281+
275282
return new ErrorWrapper(apiResponse.getError(), requestId, apiResponse.getUserMessage());
276283
}
277284

0 commit comments

Comments
 (0)