Skip to content

Commit 47d5d74

Browse files
author
Karl Rieb
committed
Remove RUNTIME annotations from generated Babel POJOs.
A bug in Android dalvik forces all classes containing RUNTIME annotations into the primary dex. This includes annotations on class fields and methods. The bug may cause multidex builds to fail if they depend on this library. Fixes T95586.
1 parent 0fa1006 commit 47d5d74

35 files changed

Lines changed: 1457 additions & 1857 deletions

ChangeLog.txt

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,10 @@
11
2.0.4
22
---------------------------------------------
3-
- Migrate build from maven to gradle
3+
- Migrate build from maven to gradle.
4+
- Improve code shrinking when using ProGuard.
5+
- Response/request serialization updated to be better optimized by ProGuard.
6+
- Properly support multidex builds
7+
- Response/request objects should no longer always be kept in primary dex.
48

59
---------------------------------------------
610
2.0.3 (2016-05-07)

ReadMe.md

Lines changed: 1 addition & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -156,19 +156,6 @@ Another workaround is to tell your OSGi container to provide that requirement: [
156156

157157
### Does this SDK require any special ProGuard rules for shrink optimizations?
158158

159-
Yes. This SDK uses Jackson JSON libraries for serialization. Specifically:
160-
161-
* [Jackson Core](https://github.com/FasterXML/jackson-core)
162-
* [Jackson Annotations](https://github.com/FasterXML/jackson-annotations)
163-
* [Jackson Databind](https://github.com/FasterXML/jackson-databind)
164-
165-
Jackson Databind makes use of reflection and annotations to map Java objects to JSON. Your ProGuard configuration should ensure Jackson annotations and Object mapping classes are kept. An example configuration is shown below:
166-
167-
```
168-
-keepattributes *Annotation*,EnclosingMethod,InnerClasses,Signature
169-
-keepnames class com.fasterxml.jackson.** { *; }
170-
-dontwarn com.fasterxml.jackson.databind.**
171-
-adaptresourcefilenames com/dropbox/core/http/trusted-certs.raw
172-
```
159+
Versions 2.0.0-2.0.3 of this SDK require specific ProGuard rules to work with shrinking enabled. However, since version **2.0.4**, the SDK no longer needs special ProGuard directives.
173160

174161
**IMPORTANT: If you are running version 2.0.x before 2.0.3, you should update to the latest Dropbox SDK version to avoid a deserialization bug that can cause Android apps that use ProGuard to crash.**

build.gradle

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -65,8 +65,6 @@ dependencies {
6565
// Important: Jackson 2.8+ will be free to use JDK7 features and no longer guarantees JDK6
6666
// compatibility
6767
compile 'com.fasterxml.jackson.core:jackson-core:2.7.4'
68-
compile 'com.fasterxml.jackson.core:jackson-annotations:2.7.4'
69-
compile 'com.fasterxml.jackson.core:jackson-databind:2.7.4'
7068

7169
compileOnly 'javax.servlet:servlet-api:2.5'
7270
compileOnly 'com.squareup.okhttp:okhttp:2.7.5'
@@ -106,6 +104,9 @@ test {
106104

107105
testLogging {
108106
events "skipped", "failed"
107+
info {
108+
events "passed", "skipped", "failed"
109+
}
109110
}
110111
}
111112

@@ -124,6 +125,9 @@ task integrationTest(type: Test) {
124125

125126
testLogging {
126127
events "skipped", "failed"
128+
info {
129+
events "passed", "skipped", "failed"
130+
}
127131
}
128132

129133
reports {

examples/android/build.gradle

Lines changed: 17 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,7 @@ buildscript {
66
}
77
dependencies {
88
classpath 'com.android.tools.build:gradle:2.1.0'
9-
10-
// NOTE: Do not place your application dependencies here; they belong
11-
// in the individual module build.gradle files
9+
classpath 'com.getkeepsafe.dexcount:dexcount-gradle-plugin:0.5.2'
1210
}
1311
}
1412

@@ -41,9 +39,8 @@ android {
4139
}
4240
debug {
4341
// to debug ProGuard rules
44-
minifyEnabled false
45-
shrinkResources false
46-
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
42+
minifyEnabled true
43+
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules-debug.pro'
4744
}
4845
}
4946

@@ -53,15 +50,27 @@ android {
5350
exclude 'META-INF/NOTICE'
5451
exclude 'META-INF/NOTICE.txt'
5552
}
53+
54+
lintOptions {
55+
disable 'InvalidPackage'
56+
}
5657
}
5758

5859
dependencies {
5960
compile group: 'com.dropbox.core', name: 'dropbox-core-sdk', version: '0-SNAPSHOT', changing: true
6061
compile 'com.android.support:appcompat-v7:23.1.1'
6162
compile 'com.android.support:design:23.1.1'
6263
compile 'com.android.support:recyclerview-v7:23.1.1'
63-
compile 'com.fasterxml.jackson.core:jackson-core:2.7.1'
64-
compile 'com.fasterxml.jackson.core:jackson-annotations:2.7.1'
64+
compile 'com.fasterxml.jackson.core:jackson-core:2.7.4'
6565
compile 'com.squareup.picasso:picasso:2.5.2'
6666
compile 'com.squareup.okhttp:okhttp:2.4.0'
6767
}
68+
69+
apply plugin: 'com.getkeepsafe.dexcount'
70+
71+
dexcount {
72+
format = "list"
73+
includeClasses = true
74+
includeFieldCount = false
75+
orderByMethodCount = true
76+
}
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
-dontobfuscate
2+
-include "proguard-rules.pro"

examples/android/proguard-rules.pro

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -16,16 +16,6 @@
1616
# public *;
1717
#}
1818

19-
# Dropbox SDK Serialization
20-
21-
-keepattributes *Annotation*,EnclosingMethod,InnerClasses,Signature
22-
-keepnames class com.fasterxml.jackson.** { *; }
23-
-dontwarn com.fasterxml.jackson.databind.**
24-
25-
# Dropbox SSL trusted certs
26-
27-
-adaptresourcefilenames com/dropbox/core/http/trusted-certs.raw
28-
2919
# OkHttp and Servlet optional dependencies
3020

3121
-dontwarn okio.**

examples/build.gradle

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@ allprojects {
77
subprojects {
88
apply plugin: 'java'
99

10-
sourceCompatibility = 1.8
11-
targetCompatibility = 1.8
10+
sourceCompatibility = JavaVersion.VERSION_1_8
11+
targetCompatibility = JavaVersion.VERSION_1_8
1212

1313
repositories {
1414
jcenter()

examples/run

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,4 +55,4 @@ for arg in "${@}" ; do
5555
i=$((i+1))
5656
done
5757

58-
exec ./gradlew --console plain --quiet ":${example_name}:run" "${project_properties[@]}"
58+
exec "${base_dir}/gradlew" -b "${base_dir}/build.gradle" --console plain --quiet ":${example_name}:run" "${project_properties[@]}"

examples/settings.gradle

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,4 +6,3 @@ include ':tutorial'
66
include ':upgrade-oauth1-token'
77
include ':upload-file'
88
include ':web-file-browser'
9-

export-generated

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ IGNORE_PATTERNS = [
2222
'.gitmodules',
2323
'/diff-generated-sources',
2424
'/release.gradle', # public repo should not include signing and release information
25+
'/proguard',
2526
]
2627

2728
cmdline_desc = """\

0 commit comments

Comments
 (0)