我是java和android开发的新手。我将使用Android Saripaar v2(感谢 Ragunath Jawahar)进行验证。
我使用安卓工作室。
在没有其他模块的新干净 android 项目上,它运行良好。
但是在我的多模块应用程序上,注释中的messageResId属性存在问题。(属性值必须是常量)
这是我的代码:
build.gradle(模块:app)
...
// workaround for "duplicate files during packaging of APK" issue
// see https://groups.google.com/d/msg/adt-dev/bl5Rc4Szpzg/wC8cylTWuIEJ
packagingOptions {
exclude 'META-INF/ASL2.0'
exclude 'META-INF/LICENSE'
exclude 'META-INF/NOTICE'
}
allprojects {
repositories {
mavenCentral()
maven { url "https://oss.sonatype.org/content/repositories/snapshots/" }
maven { url "http://files.couchbase.com/maven2/" }
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.android.support:appcompat-v7:21.0.3'
compile 'com.android.support:support-v4:21.0.3'
compile project(':auth')
}
...
build.gradle(模块:auth)
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.android.support:appcompat-v7:21.0.3'
compile 'com.facebook.android:facebook-android-sdk:3.21.1'
compile 'com.google.android.gms:play-services:6.5.87'
compile 'com.mobsandgeeks:android-saripaar:2.0-SNAPSHOT'
compile project (':other_api_module')
}
auth/java/.../SignInFragment.java此文件中的错误
public class SignInFragment extends Fragment implements View.OnClickListener, View.OnFocusChangeListener, Validator.ValidationListener{
String TAG = SignInFragment.class.getName();
private ISignInFragment iSignInFragment;
@Email(messageResId = R.string.editTextEmailValidationError) //ERROR: Attribute (R.string.editTextEmailValidationError) value must be constant
private EditText editTextEmail;
private EditText editTextPassword;
static public String EMAIL = "email";