生成签名apk后,我的评级栏不显示

时间:2018-05-04 10:53:49

标签: android keystore ratingbar signed-apk

我有一个评级栏类如下。

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;
}

当我安装apk时,通过在任何模拟器中运行,它工作得很好。但是当我使用我的密钥库生成签名的apk时,我的评级栏不会显示。

你知道可能出现什么问题吗?

1 个答案:

答案 0 :(得分:1)

打开 proguard-rules.pro

添加

-keep class * {
    public private *;
}

<强> FYI

如果您想添加 Rating 类,那么

-keep public class yourPackage.Rating 

然后 Clean-Rebuild-Run

注意

如果您设置 minifyEnabled false

,您的代码就会有效
buildTypes {
        release {
            minifyEnabled false