Signed apk getting crashed in proguard enable

瘦欲@ 提交于 2019-12-05 02:19:48

Reason : Not every Class or Library are optimized with Proguard enabled , So what Proguard do is that it removes classes if they are not optimize which results crash and bugs in project.

Solution : In your proguard.cfg file keep that classes or library which are not supported by progaurd . Try the catch all described here :
Try adding :

-keep class android.support.v7.internal.** { *; }
-keep interface android.support.v7.internal.** { *; }
-keep class android.support.v7.** { *; }
-keep interface android.support.v7.** { *; }


Or , if you are using v4 lib :

-dontwarn android.support.v4.**
-keep class android.support.v4.** { *; }
-dontwarn android.support.v7.**
-keep class android.support.v7.** { *; }


If you are using latest android studio you might found this as proguard-rules.pro


In your case try using -dontwarn as well with classname. Like your error show that it can not optimize circleimageview Library . so try to add this as well :

-dontwarn hdodenhof.**
-keep class hdodenhof.**


If still not working than downgrade your circleimageview library :
compile 'de.hdodenhof:circleimageview:1.3.0' This is working for me.

1) Keep all annotations

-keepattributes SourceFile,LineNumberTable,*Annotation*,EnclosingMethod,Signature,Exceptions,InnerClasses

2) Keep if you have any pojos or models and classes which are using for network call

Ex:

-keep class com.example.android.models.**
-keepclassmembers class com.example.android.models.** {
      *;
}
-keepclassmembers class com.example.android.network.** {
  public void set*(***);
  public *** get*();
  public *** is*();
}

3) For all the libraries you are using keep below proguard rules

Ex:

-dontwarn com.zl.reik.dilatingdotsprogressbar.**
-keep class com.zl.reik.dilatingdotsprogressbar.**{*;}
-keep interface com.zl.reik.dilatingdotsprogressbar.**{*;}

You even need to keep similar proguard rules for "foldingtabbar", as It is also a library

If the above solution does not solve, run ./gradlew app:dependencies in your repository and Send me the list of dependencies

Having the same version for all the support libraries is also very important. Sometimes libraries have recursive dependencies, where each has a different version which can lead to this error. Run:

./gradlew app:dependencies

to see the dependencies for each library and check whether they all have the same version. I already see, that you use 25.1.0 and 25.2.0 versions of support libraries. In addition, some of your libraries are old, thus, they probably use old versions.

Try to use:

-keep class beatbox.neelay.dummybeat.**{*;}
-dontwarn beatbox.neelay.dummybeat.**

instead of:

-keepnames beatbox.neelay.dummybeat.**{*;}

Proguard removes classes which are part of dependencies added the app. Try to keep them using:

-keep class hdodenhof.**
-keep class android.support.v4.** { *; }
-keep class android.support.v7.** { *; }
-keep interface android.support.v7.** { *; }
-keep class android.support.v7.internal.** { *; }
-keep interface android.support.v7.internal.** { *; }

Disable warning for dependency classes:

-dontwarn hdodenhof.**
-dontwarn android.support.v4.**
-dontwarn android.support.v7.**

In Your code :

minifyEnabled true

make this

 minifyEnabled false

hope it helps :)

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!