I've added the following code taken from here.
# JSR 305 annotations are for embedding nullability information.
-dontwarn javax.annotation.**
-keepclasseswithmembers class * {
@com.squareup.moshi.* <methods>;
}
-keep @com.squareup.moshi.JsonQualifier interface *
# The name of @JsonClass types is used to look up the generated adapter.
-keepnames @com.squareup.moshi.JsonClass class *
# Retain generated JsonAdapters if annotated type is retained.
-if @com.squareup.moshi.JsonClass class * # <- This is line 158
-keep class <1>JsonAdapter {
<init>(...);
<fields>;
}
When I try to build my app, I get the following error:
Running 'gradlew assembleStagingRelease'...
Warning: Exception while processing task java.io.IOException: proguard.ParseException: Unknown option '-if' in line 158 of file '/Users/uer/Documents/my-app/android/app/proguard-rules.pro'
FAILURE: Build failed with an exception.
Line 158 is pointed out on the script above.
Any ideas?
if requires ProGuard 6.x or newer. What version of AGP are you using?
Hey @JakeWharton thanks for the quick answer.
I have the following configuration for Gradle, if AGP stands for Android Gradle Plugin

I _think_ AGP jumped to ProGuard 6.x in 3.1. You can force old versions to use newer ProGuards by following these instructions: https://sourceforge.net/p/proguard/discussion/182455/thread/89a4d63d/. I would recommend updating though. 3.2 is about to go stable next week!
For further reference (in case somebody else gets with this problem):
3.1.4 didn't solve it as they still use ProGuard 5.3.3.3.1.4. Error was the following:Unable to find method 'proguard.KeepClassSpecification.
(ZZZZZZLproguard/ClassSpecification;)V'.
- Going back to AGP
3.0.1and manually forcing ProGuard to be6.0does the trick.
Thank you for reporting the issue @matibzurovski and your hint @JakeWharton.
I tried the resolutionStrategy which you suggested and it worked for me.
Further, I tried to use the proguard-gradle plugin which I already use here. I can confirm that it works - at least for me ^^. Please have look at this project which I currently role out for KotlinConf 2018.
Most helpful comment
For further reference (in case somebody else gets with this problem):
3.1.4didn't solve it as they still useProGuard 5.3.3.3.1.4. Error was the following: