2017-02-28 20 views
0

私はユーザーインターフェイスの検証に "UI form validation library for Android"ライブラリを使用しています。そして私はまた、例えばいくつかのカスタム検証ルールを実装しました:progaurdは注釈を保存していません

public class CellRule extends AnnotationRule<Cell, String> { 
    protected CellRule(Cell cell) { 
     super(cell); 
    } 

    @Override 
    public boolean isValid(String text) { 
     if(text.isEmpty()) { 
      return false; 
     } 

     String cellNumber = StringUtils.toStandard(text); 

     Pattern cellPattern = Pattern.compile("^(0|\\+98)9(1[0-9]|3[1-9]|2[1-9])-?[0-9]{3}-?[0-9]{4}$"); 
     Matcher cellMatcher = cellPattern.matcher(cellNumber); 

     return cellMatcher.matches(); 
    } 
} 

@ValidateUsing(CellRule.class) 
@Retention(RetentionPolicy.RUNTIME) 
@Target(ElementType.FIELD) 
public @interface Cell { 
    int sequence()   default -1; 
    int messageResId()  default -1; 
    String message()  default "Invalid Cell!"; 
} 

と私は、このコマンドを使用して登録:

Validator.registerAnnotation(Cell.class); 

をし、期待どおりに仕事をしています。私が署名されたapkを生成しようとするまで(これを有効にした状態で)、私はいくつかのエラーを出す...私がapkをチェックアウトしたとき(逆コンパイルを使って)、progaurdはapkの注釈(@interface Cell

私が登録行をコメントアウトしたとき、すべてが良いです。

答えて

0

私はすべてのライブラリがそれ自身のプロガード設定を持っていることを発見しました。おそらくライブラリのREADMEファイルに記載されています!

-keep class com.mobsandgeeks.saripaar.** {*;} 
-keep @com.mobsandgeeks.saripaar.annotation.ValidateUsing class * {*;} 
:これはトリックを行うだろうsaripaarのライブラリのため

関連する問題