Android studio 1.1.0 setting minifyEnabled true causing issues with app -
here's gradle.build file
defaultconfig { minsdkversion 15 targetsdkversion 21 versioncode 2 versionname "1.0" } buildtypes { release { minifyenabled true proguardfiles getdefaultproguardfile('proguard-android.txt'), 'proguard-rules.pro' } }
proguard-rules.pro file
-keepclassmembers class * extends de.greenrobot.dao.abstractdao { public static java.lang.string tablename; } -keep class **$properties -dontwarn com.squareup.** -dontwarn okio.** -dontwarn retrofit.** -dontwarn org.joda.time.**
i have 1 of java class as
public class endpoints { public final static string get_endpoint = "my_endpoint"; }
which use in retrofit restadapter as
restadapter restadapter = new restadapter.builder() .setendpoint(endpoints.get_endpoint) .setloglevel(restadapter.loglevel.none) .setconverter(new gsonconverter(gson)) .setclient(new okclient(busprovider.getclientinstance())) .build();
now when minifiyenabled false, entire code works fine set minifyenabled true, network call doesn't happen. app calls endpoint launched network logs dont show network request being made. can tell me whats wrong here?
proguard doesn't play many of libraries used in project.
for gson added proguard rules given gson team @ http://google-gson.googlecode.com/svn/trunk/examples/android-proguard-example/proguard.cfg
you need change
-keep class com.google.gson.examples.android.model.** { *; }
to
-keep class com.your.package.name.your.models.** { *; }
for retrofit need add
-dontwarn retrofit.** -keep class retrofit.** { *; } -keepattributes signature -keepattributes exceptions -keepclasseswithmembers class * { @retrofit.http.* <methods>; }
taken here https://github.com/square/retrofit/issues/117
for joda library added
-keep class org.joda.time.** { *; } -dontwarn org.joda.time.**
for otto need add
-dontwarn com.squareup.** -keepclassmembers class ** { @com.squareup.otto.subscribe public *; @com.squareup.otto.produce public *; }
taken here https://github.com/stephenasherson/android-ottosample/blob/master/proguard-project.txt
i added
-keep class com.squareup.okhttp.** { *; }
before using these configuration changes proguard trimmed app 3.4 mb 2 mb. after using these changes shrinks 3.2 mb going go minifyenabled false.
Comments
Post a Comment