1

我有一个评级栏类如下。

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 时,我的评级栏没有出现。

你知道可能是什么问题吗?

4

1 回答 1

1

打开你的proguard-rules.pro

添加

-keep class * {
    public private *;
}

供参考

如果你想添加Rating类然后

-keep public class yourPackage.Rating 

然后Clean-Rebuild-Run

笔记

如果您设置,您的代码将有效 minifyEnabled false

buildTypes {
        release {
            minifyEnabled false
于 2018-05-04T12:31:28.360 回答