앱 축소와 난독화를 위해
shrinkResources true
와
minifyEnabled true
를 추가한다.
app.gradle
android {
buildTypes {
debug {
signingConfig signingConfigs.debug
release {
shrinkResources true
minifyEnabled true
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
이대로 앱을 release 모드에서 테스트 할 경우 몇 라이브러리에서 난독화로 인한 충돌이 생긴다.
때문에 해당 라이브러리에 대한 예외처리를 proguard-rules.pro 에 작성해 주어야 한다.
> 공식문서 보기
각 라이브러리마다 구글링을 통해 proguard 작성법을 알 수 있다.
Retrofit
Azure Communnication
retrofit의 경우 MyApi의 class와 interface, 그리고 enum을 각각 예외 처리한 코드를 추가했다.
그리고 소셜 로그인 시 access token 을 identityToken에 잘 넣어주지 않아 model, utils 패키지를 모두 예외처리 하였다.
proguard-rules-pro
-keep class MyApi.models.* { *; }
-keep interface MyApi.apis.* { *; }
-keepclassmembers enum MyApi.models.* { *; }
-keep class com.myapp.model.** { *; }
-keep class com.myapp.utils.** { *; }
-keepclassmembers class com.myapp.model.** { *; }
-keepclassmembers class com.myapp.utils.** { *; }
-keepclassmembers enum * { *; }
-keep class com.skype.rt.** {*;}
-keep class com.azure.** {*;}
-keep class com.skype.android.** {*;}
-keep class com.microsoft.media.** {*;}
-keep class com.microsoft.dl.** {*;}
-keepattributes Signature, InnerClasses, EnclosingMethod
-keepattributes RuntimeVisibleAnnotations, RuntimeVisibleParameterAnnotations
-keepattributes AnnotationDefault
-keepclassmembers,allowshrinking,allowobfuscation interface * {
@retrofit2.http.* <methods>;
-dontwarn org.codehaus.mojo.animal_sniffer.IgnoreJRERequirement
-dontwarn javax.annotation.**
-dontwarn kotlin.Unit
-dontwarn retrofit2.KotlinExtensions
-dontwarn retrofit2.KotlinExtensions.*
-if interface * { @retrofit2.http.* <methods>; }
-keep,allowobfuscation interface <1>
-keep,allowobfuscation,allowshrinking interface retrofit2.Call