I am trying to create a release version of my app using below configuration.
buildTypes {
release {
debuggable false
minifyEnabled true
shrinkResources true
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
}
debug {
debuggable true
minifyEnabled true
shrinkResources true
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
}
}
Its working fine in debug but retrofit response.body is empty in release mode.
I tried Proguard rules as mentioned here: https://github.com/square/retrofit/blob/master/retrofit/src/main/resources/META-INF/proguard/retrofit2.pro
I also tried adding -dontobfuscate to proguard-rule.pro, tried removing proguardFiles parameter from the release type but nothing is working.
I am using following version of dependncies at app level:
implementation 'com.squareup.retrofit2:retrofit:2.9.0'
implementation 'com.squareup.retrofit2:converter-gson:2.9.0'
implementation "com.squareup.okhttp3:okhttp"
At Project Level:
id 'com.android.application' version '7.2.0' apply false
id 'com.android.library' version '7.2.0' apply false
id 'org.jetbrains.kotlin.android' version "$kotlin_version" apply false
id 'com.google.android.libraries.mapsplatform.secrets-gradle-plugin' version '2.0.1' apply false
2
Answers
Finally, solved after trying several proguard-rule.pro.
Basically, if you are using APIResponse data class. Add the proguard rule
You will have to add the below code to
proguard-rules.pro
Also add below line in
gradle.properties
file.