view raw
Robertoq Robertoq - 9 months ago 54
Android Question

View's onClick not working in ViewPager/Fragment if proguard enabled

I have a

in my Activity which is show Fragments by
. Inside the Fragments there are some view from xml and some dynamically created. When from xml I using
to handle click event and for generated views. I just use the
setOnClickListener(new View.OnClickListener...)
from code.
It's working but when I enable
only here (ViewPager.Fragments.View) click not working but everywhere else in the app yes.

My gradle:

release {
runProguard true
proguardFiles getDefaultProguardFile('proguard-android.txt'), ''

-renamesourcefileattribute SourceFile
-keepattributes SourceFile,LineNumberTable

-dontwarn butterknife.internal.**
-keep class **$$ViewInjector { *; }
-keepnames class * { @butterknife.InjectView *;}

-keep class com.parse.** { *; }
-dontwarn com.parse.**

-dontwarn com.squareup.picasso.**

-keepclassmembers class * extends {
public void *(android.view.View);

-keep class** { *; }

What is the correct ProGuard settings?


Use this :

-libraryjars   libs/android-support-v4.jar
-keep class** { *; }  
-keep interface** { *; }
-keepattributes *Annotation*