Error Java.lang.nosuchmethoderror On My Firebase Project
Solution 1:
Try to remove your valueEventListener and do this instead
first Remove this listener
ValueEventListenerpostListener=newValueEventListener() {...
change this
mDatabase = FirebaseDatabase.getInstance().getReference("https://raspi-ph.firebaseio.com/Fakultas Teknik/ph");
to this
mDatabase = FirebaseDatabase.getInstance().getReference();
and then inside your onClick use that reference to access your data. With this for inside your onDataChange you can access all your values from the different keys
mDatabase.child("Fakultas Teknik").child("ph").addValueEventListener(newValueEventListener() {
@OverridepublicvoidonDataChange(DataSnapshot dataSnapshot) {
for(DataSnapshot childSnapshot : dataSnapshot.getChildren()){
Ph ph = childSnapshot.getValue(Ph.class);
String date = ph.getDate();
Log.i("Date:",""+date);
}
}
@OverridepublicvoidonCancelled(DatabaseError databaseError) {
Toast.makeText(getApplicationContext(), databaseError.getMessage(), Toast.LENGTH_SHORT).show();
}
});
Or you can try to add your reference with getReferenceFromUrl()
mDatabase = FirebaseDatabase.getInstance().getReferenceFromUrl("https://raspi-ph.firebaseio.com/Fakultas Teknik/ph");
Solution 2:
this question is solve. i downloading google-service.json from firebase console and add it to project/app folder :)
Solution 3:
check your dependencies, make sure your Fire base core tally's with your fire base database.
For eExample
implementation 'com.google.firebase:firebase-core:16.0.1' implementation 'com.google.firebase:firebase-database:16.0.1'
not
implementation 'com.google.firebase:firebase-core:16.0.1' implementation 'com.google.firebase:firebase-database:10.0.1'
Solution 4:
I came across a similar error (not the same) with Firebase
after implementing FirebaseAuth.
After trying a lot, I removed the FirebaseCore
dependency and it worked.
Post a Comment for "Error Java.lang.nosuchmethoderror On My Firebase Project"