Skip to content

Commit 0b10349

Browse files
committed
Update Gradle Plugin and tidy up proguard settings for release build
1 parent 52526cc commit 0b10349

4 files changed

Lines changed: 57 additions & 14 deletions

File tree

app/build.gradle

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,6 @@ android {
5858
release
5959
}
6060

61-
6261
buildTypes {
6362
debug {
6463
applicationIdSuffix ".dbg"
@@ -73,7 +72,6 @@ android {
7372
minifyEnabled true
7473
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
7574
}
76-
7775
}
7876
}
7977

app/proguard-rules.pro

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

19-
# Platform calls Class.forName on types which do not exist on Android to determine platform.
20-
-dontnote retrofit2.Platform
21-
# Platform used when running on RoboVM on iOS. Will not be used at runtime.
22-
-dontnote retrofit2.Platform$IOS$MainThreadExecutor
23-
# Platform used when running on Java 8 VMs. Will not be used at runtime.
24-
-dontwarn retrofit2.Platform$Java8
25-
# Retain generic type information for use by reflection by converters and adapters.
19+
# Application classes that will be serialized/deserialized over Gson
20+
-keep class com.earthstormsoftware.motecontrol.MoteStatus { *; }
21+
-keep interface com.earthstormsoftware.motecontrol.MoteAPI { *; }
22+
23+
# Rules for using the Support classes
24+
-keep public class android.support.v7.widget.** { *; }
25+
-keep public class android.support.v7.internal.widget.** { *; }
26+
-keep public class android.support.v7.internal.view.menu.** { *; }
27+
28+
-keep public class * extends android.support.v4.view.ActionProvider {
29+
public <init>(android.content.Context);
30+
}
31+
32+
33+
## GSON 2.2.4 specific rules ##
34+
35+
# Gson uses generic type information stored in a class file when working with fields. Proguard
36+
# removes such information by default, so configure it to keep all of it.
37+
-keepattributes Signature
38+
39+
# For using GSON @Expose annotation
40+
-keepattributes *Annotation*
41+
42+
-keepattributes EnclosingMethod
43+
44+
# Gson specific classes
45+
-keep class sun.misc.Unsafe { *; }
46+
-keep class com.google.gson.stream.** { *; }
47+
48+
# Retrofit 2.X
49+
## https://square.github.io/retrofit/ ##
50+
51+
-dontwarn retrofit2.**
52+
-keep class retrofit2.** { *; }
2653
-keepattributes Signature
27-
# Retain declared checked exceptions for use by a Proxy instance.
2854
-keepattributes Exceptions
2955

30-
# Ignore warnings for okio - safe to do according to https://github.com/square/okio/issues/60
56+
-keepclasseswithmembers class * {
57+
@retrofit2.http.* <methods>;
58+
}
59+
60+
# OkHttp
61+
-keepattributes Signature
62+
-keepattributes *Annotation*
63+
-keep class okhttp3.** { *; }
64+
-keep interface okhttp3.** { *; }
65+
-dontwarn okhttp3.**
66+
67+
# Okio
68+
-keep class sun.misc.Unsafe { *; }
69+
-dontwarn java.nio.file.*
70+
-dontwarn org.codehaus.mojo.animal_sniffer.IgnoreJRERequirement
3171
-dontwarn okio.**

app/src/main/java/com/earthstormsoftware/motecontrol/MoteStatus.java

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,14 +16,19 @@
1616

1717
package com.earthstormsoftware.motecontrol;
1818

19+
import com.google.gson.annotations.SerializedName;
20+
1921
/*
2022
When Retrofit receives the response to the API call, it can parse the response, and map it to an
2123
object. In our case, the response is in JSON so we use GSON to convert that to a usable object,
2224
defined here.
2325
*/
2426
public class MoteStatus {
25-
int status;
26-
String colour;
27+
@SerializedName("status")
28+
public int status;
29+
30+
@SerializedName("colour")
31+
public String colour;
2732

2833
public int getStatus() {
2934
return status;

build.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ buildscript {
55
jcenter()
66
}
77
dependencies {
8-
classpath 'com.android.tools.build:gradle:2.2.1'
8+
classpath 'com.android.tools.build:gradle:2.2.2'
99

1010
// NOTE: Do not place your application dependencies here; they belong
1111
// in the individual module build.gradle files

0 commit comments

Comments
 (0)