gpt4 book ai didi

android - 发现两个 getter 或属性的大小写敏感度冲突的字段

转载 作者:塔克拉玛干 更新时间:2023-11-03 00:01:55 25 4
gpt4 key购买 nike

任何人都可以检查它是否有错误,因为我总是出错

com.google.firebase.database.DatabaseException: Found two getters or fields with conflicting case sensitivity for property.

这是我的代码 signupTeacherActivity:

public class signupTeacher extends AppCompatActivity {
EditText userfirstname,userlastname, useremail,userpassword,userconfirmpassword, CV,city;
private DatabaseReference mDatabase;
private FirebaseAuth mAuth;
Spinner spinner;
String defaultuserprofileimg;


@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_signup_teacher);
getSupportActionBar().setTitle("Sign Up");
findViewByIds();

ArrayAdapter<CharSequence> adapter = ArrayAdapter.createFromResource(this, R.array.subject_array, android.R.layout.simple_spinner_item);
adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
spinner.setAdapter(adapter);
}

public void signUpUser(View view) {
if(useremail.getText().toString().length()==0 || userpassword.getText().toString().length()==0||userfirstname.getText().length()==0 ||userconfirmpassword.getText().length()==0 ||userlastname.getText().length()==0){
Toast.makeText(signupTeacher.this, "Please enter all the fields to proceed further.",
Toast.LENGTH_SHORT).show();
}else {
if(spinner.getSelectedItem().toString().equals("Select a Subject")){
Toast.makeText(signupTeacher.this, "Please select a valid Subject.", Toast.LENGTH_LONG).show();
}
else {
mAuth = FirebaseAuth.getInstance();
mAuth.createUserWithEmailAndPassword(useremail.getText().toString(), userpassword.getText().toString())
.addOnCompleteListener(this, new OnCompleteListener<AuthResult>() {
@Override
public void onComplete(@NonNull Task<AuthResult> task) {
Log.d("demo", "createUserWithEmail:onComplete:" + task.isSuccessful());

if (!task.isSuccessful()) {
Toast.makeText(signupTeacher.this, task.getException().toString(),
Toast.LENGTH_SHORT).show();
} else {
mDatabase = FirebaseDatabase.getInstance().getReference();
Teacher user = new Teacher(userfirstname.getText().toString(), userlastname.getText().toString(), useremail.getText().toString(), userpassword.getText().toString() , CV.getText().toString(), spinner.getSelectedItem().toString(), city.getText().toString(),task.getResult().getUser().getUid().toString(), defaultuserprofileimg);
mDatabase.child("Teachers").child(task.getResult().getUser().getUid().toString()).setValue(user);
Intent i = new Intent(signupTeacher.this, MainActivity.class);
startActivity(i);
Toast.makeText(signupTeacher.this, "Succesfully registered. Please login with the created credentials",
Toast.LENGTH_LONG).show();
mAuth = FirebaseAuth.getInstance();
mAuth.signOut();
finish();
}

}

});
}
}

}

public void goToLogin(View view) {
Intent i=new Intent(signupTeacher.this,MainActivity.class);
startActivity(i);
finish();

}
private void findViewByIds() {
userfirstname= (EditText)findViewById(R.id.firstname);
userlastname= (EditText) findViewById(R.id.lastname);
userpassword= (EditText) findViewById(R.id.password);
userconfirmpassword= (EditText)findViewById(R.id.confirmpassword);
useremail= (EditText) findViewById(R.id.email);
spinner = (Spinner) findViewById(R.id.spSubject);
CV = (EditText) findViewById(R.id.cv);
city = (EditText) findViewById(R.id.City);

}}

类主任:

public class Teacher  implements Serializable {
String firstlame,lastname,useremail,userpassword, CV, spinner, city, userkey,userimageuri;

public String getFirstlame() {
return firstlame;
}

public void setFirstlame(String firstlame) {
this.firstlame = firstlame;
}

public String getLastname() {
return lastname;
}

public void setLastname(String lastname) {
this.lastname = lastname;
}

public String getUseremail() {
return useremail;
}

public void setUseremail(String useremail) {
this.useremail = useremail;
}

public String getUserpassword() {
return userpassword;
}

public void setUserpassword(String userpassword) {
this.userpassword = userpassword;
}

public String getCv() {
return CV;
}

public void setCv(String CV) {
this.CV = CV;
}

public String getSpinner() {
return spinner;
}

public void setSpinner(String spinner) {
this.spinner = spinner;
}
public String getCity() {return city; }

public void setCity(String city) {
this.city = city;
}

public String getUserkey() {
return userkey;
}

public void setUserkey(String userkey) {
this.userkey = userkey;
}

public String getUserimageuri() {
return userimageuri;
}

public void setUserimageuri(String userimageuri) {
this.userimageuri = userimageuri;
}


public Teacher(String firstlame, String lastname, String useremail, String userpassword, String CV, String spSubject , String City, String userkey, String userimageuri ) {

this.firstlame = firstlame;
this.lastname = lastname;
this.useremail = useremail;
this.userpassword = userpassword;
this.CV = CV;
this.spinner = spSubject;
this.city = City;
this.userkey=userkey;
this.userimageuri=userimageuri;

}

public Teacher(){

}}

日志:

04-09 21:41:30.570 12739-12739/com..example.*.*hers E/AndroidRuntime: FATAL EXCEPTION: main
Process: com.example.faay.hireteachers, PID: 12739
com.google.firebase.database.DatabaseException: Found two getters or fields with conflicting case sensitivity for property: cv
at com.google.android.gms.internal.zzbqi$zza.zzjs(Unknown Source)
at com.google.android.gms.internal.zzbqi$zza.<init>(Unknown Source)
at com.google.android.gms.internal.zzbqi.zzi(Unknown Source)
at com.google.android.gms.internal.zzbqi.zzax(Unknown Source)
at com.google.android.gms.internal.zzbqi.zzaw(Unknown Source)
at com.google.firebase.database.DatabaseReference.zza(Unknown Source)
at com.google.firebase.database.DatabaseReference.setValue(Unknown Source)
at com.example.faay.hireteachers.signupTeacher$1.onComplete(signupTeacher.java:63)
at com.google.android.gms.tasks.zzc$1.run(Unknown Source)
at android.os.Handler.handleCallback(Handler.java:739)
at android.os.Handler.dispatchMessage(Handler.java:95)
at android.os.Looper.loop(Looper.java:158)
at android.app.ActivityThread.main(ActivityThread.java:7224)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1230)

感谢您的帮助!

最佳答案

尝试固定您的字段和方法的大写。 firstName, getFirstName...等

您的错误在 CV 字段上,该方法应该是 setCV 以匹配该字段的大小写,但是,您应该将其命名为 cv 遵循 Java 命名争用。然后方法是 getsetCv

public String getCv() {
return cv;
}

public void setCv(String cv) {
this.cv = cv;
}

我还建议不要将密码存储为对象的一部分。特别是如果它们是纯文本。您将密码发送到数据库以检查有效性或更新;读出它们并在别处坚持它们很少是一个好主意

关于android - 发现两个 getter 或属性的大小写敏感度冲突的字段,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43310833/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com