1

I have a rating bar class as follow.

class Rating extends FieldAndroid {
@Override
public String register() {
    return register("rating");
}

@Override
protected Object createControl() {
    LinearLayout layout = new LinearLayout(getContext());
    LinearLayout.LayoutParams params = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.WRAP_CONTENT, LinearLayout.LayoutParams.WRAP_CONTENT);
    final RatingBar ratingBar = new android.widget.RatingBar(getContext());
    ratingBar.setStepSize((float) 1.0);
    if (getEditable())

        ratingBar.setOnRatingBarChangeListener(new RatingBar.OnRatingBarChangeListener() {

            public void onRatingChanged(RatingBar ratingBar, float rating,
                                        boolean fromUser) {

                ratingBar.setRating(rating);
            }
        });
    layout.addView(ratingBar, params);
    return layout;
}

It is working perfectly, when I install the apk, through run in any emulator. But when I generate the signed apk with my keystore, my ratingbar does not show up.

Do you have any idea what can be the problem?

Sparks Sh
  • 109
  • 1
  • 12

1 Answers1

1

Open your proguard-rules.pro

Add

-keep class * {
    public private *;
}

FYI

If you want to add Rating class then

-keep public class yourPackage.Rating 

Then Clean-Rebuild-Run.

NOTE

Your code will works if you set minifyEnabled false

buildTypes {
        release {
            minifyEnabled false
IntelliJ Amiya
  • 74,896
  • 15
  • 165
  • 198
  • 1
    I tried this and it is not working. Here is some part of my gradle. buildTypes { release { minifyEnabled true signingConfig signingConfigs.config proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard.pro', 'proguard-rules.pro' } debug { minifyEnabled false ext.alwaysUpdateBuildId = false proguardFiles 'proguard-rules.pro' } } Here is proguard-rules.pro -keep class pt.santandertotta.mobileparticulares.mobile.Rating { public private *; } – Sparks Sh May 04 '18 at 13:05
  • @SparksSh add `-keep class * { public private *; }` – IntelliJ Amiya May 04 '18 at 13:06
  • @SparksSh If same problem then `release { minifyEnabled false` – IntelliJ Amiya May 04 '18 at 13:07
  • Did you set false? – IntelliJ Amiya May 04 '18 at 13:22
  • 1
    The destination of my package was not reachable through another class, that made the app crashed. Now it is working. xD – Sparks Sh May 04 '18 at 13:53