Android - ProGuard
ProGuard 설정시 RemonSDK의 Setting이 필요합니다. SDK에서 쓰이는 옵션과 종류에대해 정리합니다.

gradle.build

gradle.build
1
defaultConfig {
2
...
3
consumerProguardFiles 'consumer-rules.pro'
4
}
5
6
buildTypes {
7
release {
8
minifyEnabled false
9
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
10
}
11
12
debug {
13
minifyEnabled false
14
shrinkResources false
15
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
16
}
17
}
Copied!

consumer-rules.pro

proguard-rules.pro
1
-keep class com.remotemonster.sdk.* { *;}
2
-keep class com.remotemonster.sdk.data.** { *;}
3
-keep class com.remotemonster.sdk.util.Logger{ *;}
4
-keep enum com.remotemonster.sdk.data.ChannelStatus { *;}
5
-keep enum com.remotemonster.sdk.data.ChannelType { *;}
6
7
# webrtc
8
-keep class org.webrtc.** { *; }
9
-keep interface org.webrtc.** { *; }
10
11
# netty 4.0
12
-dontwarn io.netty.**
13
-keep class io.netty.** { *;}
14
-keep interface io.netty.** { *;}
15
16
# Slf4j for android
17
-keep class org.slf4j.** { *;}
18
-keep interface org.slf4j.** { *; }
19
20
# Jzlib
21
-keep class com.jcraft.jzlib.** { *; }
22
-keep interface com.jcraft.jzlib.** { *; }
23
24
#################################################################################################
25
### https://github.com/google/gson/blob/master/examples/android-proguard-example/proguard.cfg ###
26
#################################################################################################
27
##---------------Begin: proguard configuration for Gson ----------
28
# Gson uses generic type information stored in a class file when working with fields. Proguard
29
# removes such information by default, so configure it to keep all of it.
30
-keepattributes Signature
31
32
# For using GSON @Expose annotation
33
-keepattributes *Annotation*
34
35
# Gson specific classes
36
-dontwarn sun.misc.**
37
#-keep class com.google.gson.stream.** { *; }
38
39
40
# Prevent proguard from stripping interface information from TypeAdapter, TypeAdapterFactory,
41
# JsonSerializer, JsonDeserializer instances (so they can be used in @JsonAdapter)
42
-keep class * extends com.google.gson.TypeAdapter
43
-keep class * implements com.google.gson.TypeAdapterFactory
44
-keep class * implements com.google.gson.JsonSerializer
45
-keep class * implements com.google.gson.JsonDeserializer
46
47
# Prevent R8 from leaving Data object members always null
48
-keepclassmembers,allowobfuscation class * {
49
@com.google.gson.annotations.SerializedName <fields>;
50
}
51
52
##---------------End: proguard configuration for Gson ----------
53
54
#######################################################################
55
### https://github.com/FasterXML/jackson-docs/wiki/JacksonOnAndroid ###
56
#######################################################################
57
# Proguard configuration for Jackson 2.x
58
-dontwarn com.fasterxml.jackson.databind.**
59
-keepclassmembers class * {
60
@com.fasterxml.jackson.annotation.* *;
61
}
62
63
64
########################################################################################################
65
### https://github.com/square/okio/blob/master/okio/src/jvmMain/resources/META-INF/proguard/okio.pro ###
66
########################################################################################################
67
# Animal Sniffer compileOnly dependency to ensure APIs are compatible with older versions of Java.
68
-dontwarn org.codehaus.mojo.animal_sniffer.*
69
70
71
############################################################################################################
72
### https://github.com/square/okhttp/blob/master/okhttp/src/main/resources/META-INF/proguard/okhttp3.pro ###
73
############################################################################################################
74
# JSR 305 annotations are for embedding nullability information.
75
-dontwarn javax.annotation.**
76
77
# A resource is loaded with a relative path so the package of this class must be preserved.
78
-keepnames class okhttp3.internal.publicsuffix.PublicSuffixDatabase
79
80
# Animal Sniffer compileOnly dependency to ensure APIs are compatible with older versions of Java.
81
-dontwarn org.codehaus.mojo.animal_sniffer.*
82
83
# OkHttp platform used only on JVM and when Conscrypt dependency is available.
84
-dontwarn okhttp3.internal.platform.ConscryptPlatform
85
86
87
##################################################################################################################
88
### https://github.com/square/retrofit/blob/master/retrofit/src/main/resources/META-INF/proguard/retrofit2.pro ###
89
##################################################################################################################
90
# Retrofit does reflection on generic parameters. InnerClasses is required to use Signature and
91
# EnclosingMethod is required to use InnerClasses.
92
-keepattributes Signature, InnerClasses, EnclosingMethod
93
94
# Retrofit does reflection on method and parameter annotations.
95
-keepattributes RuntimeVisibleAnnotations, RuntimeVisibleParameterAnnotations
96
97
# Retain service method parameters when optimizing.
98
-keepclassmembers,allowshrinking,allowobfuscation interface * {
99
@retrofit2.http.* <methods>;
100
}
101
102
# Ignore annotation used for build tooling.
103
-dontwarn org.codehaus.mojo.animal_sniffer.IgnoreJRERequirement
104
105
# Ignore JSR 305 annotations for embedding nullability information.
106
-dontwarn javax.annotation.**
107
108
# Guarded by a NoClassDefFoundError try/catch and only used when on the classpath.
109
-dontwarn kotlin.Unit
110
111
# Top-level functions that can only be used by Kotlin.
112
-dontwarn retrofit2.KotlinExtensions
113
-dontwarn retrofit2.KotlinExtensions$*
114
115
# With R8 full mode, it sees no subtypes of Retrofit interfaces since they are created with a Proxy
116
# and replaces all potential values with null. Explicitly keeping the interfaces prevents this.
117
-if interface * { @retrofit2.http.* <methods>; }
118
-keep,allowobfuscation interface <1>
Copied!

proguard-rules.pro

proguard-rules.pro
1
# Add project specific ProGuard rules here.
2
# By default, the flags in this file are appended to flags specified
3
# in /home/calmglow/dev/Android/tools/proguard/proguard-android.txt
4
# You can edit the include path and order by changing the proguardFiles
5
# directive in build.gradle.
6
#
7
# For more details, see
8
# http://developer.android.com/guide/developing/tools/proguard.html
9
10
# Add any project specific keep options here:
11
12
# If your project uses WebView with JS, uncomment the following
13
# and specify the fully qualified class name to the JavaScript interface
14
# class:
15
#-keepclassmembers class fqcn.of.javascript.interface.for.webview {
16
# public *;
17
#}
18
-keepattributes SourceFile,LineNumberTable, InnerClasses, Exceptions, Signature
19
-keepattributes *Annotation*
20
-dontoptimize
21
-dontwarn org.**
22
-dontwarn retrofit2.**
23
24
-keep class com.remotemonster.sdk.* { *;}
25
-keep class com.remotemonster.sdk.data.** { *;}
26
-keep class com.remotemonster.sdk.util.Logger{ *;}
27
-keep class com.remotemonster.sdk.core.RemonExternalCapturer{ *;}
28
-keep class com.remotemonster.sdk.data.Channel{ *;}
29
-keep class com.remotemonster.sdk.data.InitMessage{ *;}
30
-keep enum com.remotemonster.sdk.data.ChannelStatus{ *;}
31
-keep enum com.remotemonster.sdk.data.ChannelType{ *;}
32
-keep class org.** { *;}
33
-keep interface org.** { *;}
34
35
-keepclasseswithmembers class * {
36
@retrofit2.http.* <methods>;
37
}
38
-keep class retrofit2.** { *; }
Copied!