Intro: I am trying to build an android app that displays info about books (using Google books API).I have recently added firebase to the app. At this moment I can log in or register to the app,I can search for books (with search view) and I have added a button for every book listed in the ListView that is created from the query.I added functionality to the button as it follows: the button (if pressed) should add the current book(in the Listview) to FireBase.
My next step is to retrieve all the books added by users in another activity called CatalogActivity
public class CatalogActivity extends AppCompatActivity {
@Override
protected void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_catalog);
GridView catalogListView = (GridView) findViewById(R.id.CatalogGridList);
final List<BookObject> books = new ArrayList<BookObject>();
FirebaseDatabase database = FirebaseDatabase.getInstance();
DatabaseReference databaseReference = database.getReference();
databaseReference.child("books").addValueEventListener(new ValueEventListener() {
@Override
public void onDataChange(DataSnapshot dataSnapshot) {
Iterable<DataSnapshot> children = dataSnapshot.getChildren();
for (DataSnapshot child : children) {
BookObject book = child.getValue(BookObject.class);
books.add(book);
}
}
@Override
public void onCancelled(DatabaseError databaseError) {
}
});
CatalogAdapter catalogAdapter = new CatalogAdapter(this, books);
catalogListView.setAdapter(catalogAdapter);
}
}
For better understanding this is the Firebase Data tab:
When I run the app and I click on CatalogActivity the app crashes.
I have used debugging with break-points and I got to the following conclusions:
-database instance and reference are obtained correctly
-snapshot of all BookObjects is obtained correctly (dataSnapshot
)
-first child snapshot (child
) is obtained correctly ( could not tell if the first book is added to books
as well)
-pressing F8 again: app jumps to Looper Class at loop method and my app crashes.
What could be causing the app to crash?
Gist of BookObject
class:BookObject
Crash log:
07-31 22:40:38.308 15567-15567/com.example.android.booktrade_v10 E/AndroidRuntime: FATAL EXCEPTION: main
Process: com.example.android.booktrade_v10, PID: 15567
com.google.firebase.database.DatabaseException: Found two getters or fields with conflicting case sensitivity for property: authors
at com.google.android.gms.internal.zh.zzhe(Unknown Source)
at com.google.android.gms.internal.zh.<init>(Unknown Source)
at com.google.android.gms.internal.zg.zzf(Unknown Source)
at com.google.android.gms.internal.zg.zzb(Unknown Source)
at com.google.android.gms.internal.zg.zza(Unknown Source)
at com.google.firebase.database.DataSnapshot.getValue(Unknown Source)
at com.example.android.booktrade_v10.CatalogActivity$1.onDataChange(CatalogActivity.java:40)
at com.google.android.gms.internal.to.zza(Unknown Source)
at com.google.android.gms.internal.vj.zzHX(Unknown Source)
at com.google.android.gms.internal.vp.run(Unknown Source)
at android.os.Handler.handleCallback(Handler.java:751)
at android.os.Handler.dispatchMessage(Handler.java:95)
at android.os.Looper.loop(Looper.java:154)
at android.app.ActivityThread.main(ActivityThread.java:6316)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:872)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:762)
Any help is highly appreciated.