I'm trying to load the data from my Firebase db in the application but for some reason it wont work. I don't know what happens or where it crashes cause it doesn't say anything.
Here I set the adapter
final ArrayAdapter<Pair<String, Double>> adapter = new ArrayAdapter<>(this, android.R.layout.simple_list_item_1, getMinorDetails());
TruckListView.setAdapter(adapter);
And to access the Firebase database I have this piece of code
public List<Truck> getTrucksFromFirebase() {
mDatabase = FirebaseDatabase.getInstance().getReference();
// Attach an listener to read the data at our posts reference
mDatabase.addValueEventListener(new ValueEventListener() {
@Override
public void onDataChange(DataSnapshot snapshot) {
System.out.println("There are " + snapshot.getChildrenCount() + " trucks");
for (DataSnapshot postSnapshot: snapshot.getChildren()) {
for (DataSnapshot postSnapshot2: snapshot.getChildren()) {
Truck truck = postSnapshot2.getValue(Truck.class);
trucks.add(truck);
}
}
}
@Override
public void onCancelled(DatabaseError databaseError) {
}
});
return trucks;
}
My database looks like this:
trucks {
truck1 { ....data }
truck2 { }
truck3 { }
}
Im trying to get the trucks and add them intoa list I have defined in my class. But for some reason the app is crashing and it won't read anything from the db. It never even enters to print the message. What am I doing wrong? I'm calling this class in the onCreate method of my activity.
V/FA: Connection attempt already in progress
V/FA: Activity paused, time: 170869535
D/libGLESv1: DTS_GLAPI : DTS is not allowed for Package : com.example.melisaam.logintest
D/ViewRootImpl: MSG_RESIZED_REPORT: ci=Rect(0, 96 - 0, 0) vi=Rect(0, 96 - 0, 0) or=1
D/FA: Connected to remote service
V/FA: Processing queued up service tasks: 3
W/ResourcesManager: getTopLevelResources: /data/app/com.example.melisaam.logintest-2/base.apk / 1.0 running in com.example.melisaam.logintest rsrc of package com.example.melisaam.logintest
V/FA: onActivityCreated
D/AbsListView: Get MotionRecognitionManager
E/MotionRecognitionManager: mSContextService = android.hardware.scontext.ISContextService$Stub$Proxy@2010181
E/MotionRecognitionManager: motionService = com.samsung.android.motion.IMotionRecognitionService$Stub$Proxy@f3b34bd
E/MotionRecognitionManager: motionService = com.samsung.android.motion.IMotionRecognitionService$Stub$Proxy@f3b34bd
I/DynamiteModule: Considering local module com.google.android.gms.firebase_database:4 and remote module com.google.android.gms.firebase_database:4
I/DynamiteModule: Selected remote version of com.google.android.gms.firebase_database, version >= 4
W/System: ClassLoader referenced unknown path: /data/user/0/com.google.android.gms/app_chimera/m/00000015/n/arm64-v8a
W/ResourcesManager: getTopLevelResources: /data/user/0/com.google.android.gms/app_chimera/m/00000015/DynamiteModulesC_GmsCore_prodmnc_alldpi_release.apk / 1.0 running in com.example.melisaam.logintest rsrc of package com.example.melisaam.logintest
D/ResourcesManager: For user 0 new overlays fetched Null
W/ResourcesManager: getTopLevelResources: /data/user/0/com.google.android.gms/app_chimera/m/00000015/DynamiteModulesC_GmsCore_prodmnc_alldpi_release.apk / 1.0 running in com.example.melisaam.logintest rsrc of package com.example.melisaam.logintest
Disconnected from the target VM, address: 'localhost:8600', transport: 'socket'
This is all the logs that appear. Basically the app starts, becomes unresponsive, dies.
I ran the debug and it seems it doesn't get inside the addValueEventListener... or at least it doesn't like something before that
I/InjectionManager: dispatchPrepareOptionsMenu :com.example.melisaam.logintest.ListItemsActivity
D/ViewRootImpl: MSG_RESIZED_REPORT: ci=Rect(0, 96 - 0, 0) vi=Rect(0, 96 - 0, 0) or=1
I/Timeline: Timeline: Activity_idle id: android.os.BinderProxy@5c27d76 time:72996221
I/Timeline: Timeline: Activity_idle id: android.os.BinderProxy@57e97f6 time:72996221
V/ActivityThread: updateVisibility : ActivityRecord{44b23d3 token=android.os.BinderProxy@57e97f6 {com.example.melisaam.logintest/com.example.melisaam.logintest.MainActivity}} show : false
I/System.out: There are 1 trucks
D/AndroidRuntime: Shutting down VM
E/AndroidRuntime: FATAL EXCEPTION: main
Process: com.example.melisaam.logintest, PID: 30436
com.google.firebase.database.DatabaseException: Class com.example.melisaam.logintest.Truck is missing a constructor with no arguments
at com.google.android.gms.internal.zzbqi$zza.zze(Unknown Source)
at com.google.android.gms.internal.zzbqi$zza.zzaG(Unknown Source)
at com.google.android.gms.internal.zzbqi.zze(Unknown Source)
at com.google.android.gms.internal.zzbqi.zzb(Unknown Source)
at com.google.android.gms.internal.zzbqi.zza(Unknown Source)
at com.google.firebase.database.DataSnapshot.getValue(Unknown Source)
at com.example.melisaam.logintest.ListItemsActivity$3.onDataChange(ListItemsActivity.java:128)
at com.google.android.gms.internal.zzbmz.zza(Unknown Source)
at com.google.android.gms.internal.zzbnz.zzYj(Unknown Source)
at com.google.android.gms.internal.zzboc$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:7229)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1230)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1120)
W/DynamiteModule: Local module descriptor class for com.google.firebase.auth not found.
W/ResourcesManager: getTopLevelResources: /data/app/com.google.android.gms-1/base.apk / 1.0 running in com.example.melisaam.logintest rsrc of package com.google.android.gms
D/ResourcesManager: For user 0 new overlays fetched Null
I/Process: Sending signal. PID: 30436 SIG: 9
Application terminated.