Я использую второе действие для сохранения данных в базе данных Firestore. Моё первое действие выводит меня на второе действие с намерением, где есть редактирование текстов, чтобы получить данные от пользователя и сохранить их в базе данных Firestore ... Но когда я нажимаю натекстовое представление не предназначено для второго действия, и приложение принудительно останавливается и возвращается к домашнему действию.
Намерение хорошо работает с другими действиями ... Нет ошибок компилятора ...
Моя Javaкод первой активности.Это задание работает хорошо
public class Adminstration extends AppCompatActivity {
Spinner service_array;
Button update;
EditText vna;
TextView newentry;
NotificationCompat.Builder builder;
DatabaseReference databaseJob;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_adminstration);
ImageView car = (ImageView) findViewById(R.id.i1);
car.setImageResource(R.drawable.car);//Image
databaseJob = FirebaseDatabase.getInstance().getReference("Jobs");
vna = (EditText) findViewById(R.id.vna);
update = (Button) findViewById(R.id.update);
newentry = (TextView) findViewById(R.id.newentry);
newentry.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
Intent create = new Intent(Adminstration.this,Car_Entry.class);
startActivity(create);
}
});
Мое второе действие, которое не открывается при использовании намерения.
public class Car_Entry extends AppCompatActivity {
EditText ed1, ed2, ed3;
Button bu;
private FirebaseFirestore db;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_car__entry);
db = FirebaseFirestore.getInstance();
ed1 = (EditText) findViewById(R.id.ed1);
ed2 = (EditText) findViewById(R.id.ed2);
ed3 = (EditText) findViewById(R.id.ed3);
bu = (Button) findViewById(R.id.bu);
bu.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
String name = ed1.getText().toString().trim();
String veno = ed2.getText().toString().trim();
String progress = ed3.getText().toString().trim();
if (!validateInputs(name, veno, progress)) {
CollectionReference dbProgress = db.collection("Customers");
Customer customer = new Customer(
name,
veno,
progress
);
dbProgress.add(customer)
.addOnSuccessListener(new OnSuccessListener<DocumentReference>() {
@Override
public void onSuccess(DocumentReference documentReference) {
Toast.makeText(Car_Entry.this, "Client Added", Toast.LENGTH_SHORT).show();
}
})
.addOnFailureListener(new OnFailureListener() {
@Override
public void onFailure(@NonNull Exception e) {
Toast.makeText(Car_Entry.this, e.getMessage(), Toast.LENGTH_SHORT).show();
}
});
}
}
});
}
private boolean validateInputs(String name, String vno, String progress) {
if (name.isEmpty()) {
ed1.setError("Name required");
ed1.requestFocus();
return true;
}
if (vno.isEmpty()) {
ed2.setError("Name required");
ed2.requestFocus();
return true;
}
if (progress.isEmpty()) {
ed3.setError("Name required");
ed3.requestFocus();
return true;
}
return false;
}
}
Мой класс Java для клиента
public class Customer{
private String name,veno,progress;
public Customer() {
}
public Customer(String name, String veno, String progress) {
this.name = name;
this.veno = veno;
this.progress = progress;
}
public String getName() {
return name;
}
public String getVeno() { (Here it is saying method Veno is not used)
return veno;
}
public String getProgress() {
return progress;
}}
Мой logcat
12-20 23:41:19.018 5379-5379/com.progresstracker E/AndroidRuntime: FATAL EXCEPTION: main
Process: com.progresstracker, PID: 5379
java.lang.NoClassDefFoundError: Failed resolution of: Lcom/google/android/gms/common/internal/zzbq;
at com.google.firebase.firestore.FirebaseFirestore.zze(Unknown Source)
at com.google.firebase.firestore.FirebaseFirestore.getInstance(Unknown Source)
at com.progresstracker.Car_Entry.onCreate(Car_Entry.java:29)
at android.app.Activity.performCreate(Activity.java:6974)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1118)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2900)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3012)
at android.app.ActivityThread.-wrap12(ActivityThread.java)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1716)
at android.os.Handler.dispatchMessage(Handler.java:110)
at android.os.Looper.loop(Looper.java:232)
at android.app.ActivityThread.main(ActivityThread.java:6802)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1103)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:964)
Caused by: java.lang.ClassNotFoundException: Didn't find class "com.google.android.gms.common.internal.zzbq" on path: DexPathList[[zip file "/data/app/com.progresstracker-2/base.apk", zip file "/data/app/com.progresstracker-2/split_lib_dependencies_apk.apk", zip file "/data/app/com.progresstracker-2/split_lib_slice_0_apk.apk", zip file "/data/app/com.progresstracker-2/split_lib_slice_1_apk.apk", zip file "/data/app/com.progresstracker-2/split_lib_slice_2_apk.apk", zip file "/data/app/com.progresstracker-2/split_lib_slice_3_apk.apk", zip file "/data/app/com.progresstracker-2/split_lib_slice_4_apk.apk", zip file "/data/app/com.progresstracker-2/split_lib_slice_5_apk.apk", zip file "/data/app/com.progresstracker-2/split_lib_slice_6_apk.apk", zip file "/data/app/com.progresstracker-2/split_lib_slice_7_apk.apk", zip file "/data/app/com.progresstracker-2/split_lib_slice_8_apk.apk", zip file "/data/app/com.progresstracker-2/split_lib_slice_9_apk.apk"],nativeLibraryDirectories=[/data/app/com.progresstracker-2/lib/arm64, /system/lib64, /vendor/lib64]]
at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:56)
at java.lang.ClassLoader.loadClass(ClassLoader.java:380)
at java.lang.ClassLoader.loadClass(ClassLoader.java:312)
at com.google.firebase.firestore.FirebaseFirestore.zze(Unknown Source)
at com.google.firebase.firestore.FirebaseFirestore.getInstance(Unknown Source)
at com.progresstracker.Car_Entry.onCreate(Car_Entry.java:29)
at android.app.Activity.performCreate(Activity.java:6974)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1118)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2900)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3012)
at android.app.ActivityThread.-wrap12(ActivityThread.java)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1716)
at android.os.Handler.dispatchMessage(Handler.java:110)
at android.os.Looper.loop(Looper.java:232)
at android.app.ActivityThread.main(ActivityThread.java:6802)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1103)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:964)