Android Firebase Database Exception while runTransaction - android

I am using TransactionHandler to push a data object as there can be concurrency issues. but while doing that I am getting the below exception:
09-15 19:12:20.193 3196-3196/com.teja.twaters D/com.teja.twaters.utils.FirebaseUtil: isComplete - false
09-15 19:12:20.207 3196-3196/com.teja.twaters D/com.teja.twaters.utils.FirebaseUtil: databaseError - DatabaseError: User code called from the Firebase Database runloop threw an exception:
java.lang.StackOverflowError: stack size 1037KB
at java.lang.reflect.Method.invoke(Native Method)
at com.google.android.gms.internal.zzaln$zza.zzce(Unknown Source)
at com.google.android.gms.internal.zzaln.zzbw(Unknown Source)
at com.google.android.gms.internal.zzaln.zzcd(Unknown Source)
at com.google.android.gms.internal.zzaln$zza.zzce(Unknown Source)
at com.google.android.gms.internal.zzaln.zzbw(Unknown Source)
at com.google.android.gms.internal.zzaln.zzbw(Unknown Source)
at com.google.android.gms.internal.zzaln.zzcd(Unknown Source)
at com.google.android.gms.internal.zzaln$zza.zzce(Unknown Source)
at com.google.android.gms.internal.zzaln.zzbw(Unknown Source)
at com.google.android.gms.internal.zzaln.zzcd(Unknown Source)
at com.google.android.gms.internal.zzaln$zza.zzce(Unknown Source)
at com.google.android.gms.internal.zzaln.zzbw(Unknown Source)
at com.google.android.gms.internal.zzaln.zzbw(Unknown Source)
at com.google.android.gms.internal.zzaln.zzcd(Unknown Source)
at com.google.android.gms.internal.zzaln$zza.zzce(Unknown Source)
at com.google.android.gms.internal.zzaln.zzbw(Unknown Source)
at com.google.android.gms.internal.zzaln.zzcd(Unknown Source)
at com.google.android.gms.internal.zzaln$zza.zzce(Unknown Source)
at com.google.android.gms.internal.zzaln.zzbw(Unknown Source)
at com.google.android.gms.internal.zzaln.zzbw(Unknown Source)
at com.google.android.gms.internal.zzaln.zzcd(Unknown Source)
at com.google.android.gms.internal.zzaln$zza.zzce(Unknown Source)
at com.google.android.gms.internal.zzaln.zzbw(Unknown Source)
at com.google.android.gms.internal.zzaln.zzcd(Unknown Source)
at com.google.android.gms.internal.zzaln$zza.zzce(Unknown Source)
at com.google.android.gms.internal.zzaln.zzbw(Unknown Source)
at com.google.android.gms.internal.zzaln.zzbw(Unknown Source)
at com.google.android.gms.internal.zzaln.zzcd(Unknown Source)
at com.google.android.gms.internal.zzaln$zza.zzce(Unknown Source)
at com.google.android.gms.internal.zzaln.zzbw(Unknown Source)
at com.google.android.gms.internal.zzaln.zzcd(Unknown Source)
at com.google.android.gms.internal.zzaln$zza.zzce(Unknown Source)
at com.google.android.gms.internal.zzaln.zzbw(Unknown Source)
at com.google.android.gms.internal.zzaln.zzbw(Unknown Source)
at com.google.android.gms.internal.zzaln.zzcd(Unknown Source)
at com.google.android.gms.internal.zzaln$zza.zzce(Unknown Source)
at com.google.android.gms.internal.zzaln.zzbw(Unknown Source)
at com.google.android.gms.internal.zzaln.zzcd(Unknown Source)
at com.google.android.gms.internal.zzaln$zza.zzce(Unknown Source)
at com.google.android.gms.internal.zzaln.zzbw(Unknown Source)
at com.google.android.gms.internal.zzaln.zzbw(Unknown Source)
at com.google.android.gms.internal.zzaln.zzcd(Unknown Source)
at com.google.android.gms.internal.zzaln$zza.zzce(Unknown Source)
at com.google.android.gms.internal.zzaln.zzbw(Unknown Source)
at com.google.android.gms.internal.zzaln.zzcd(Unknown Source)
at com.google.android.gms.internal.zzaln$zza.zzce(Unknown Source)
at com.google.android.gms.internal.zzaln.zzbw(Unknown Source)
at com.google.android.gms.internal.zzaln.zzbw(Unknown Source)
at com.google.android.gms.internal.zzaln.zzcd(Unknown Source)
at com.google.android.gms.internal.zzaln$zza.zzce(Unknown Source)
at com.google.android.gms.internal.zzaln.zzbw(Unknown Source)
at com.google.android.gms.internal.zzaln.zzcd(Unknown Source)
at com.google.android.gms.internal.zzaln$zza.zzce(Unknown Source)
at com.google.android.gms.internal.zzaln.zzbw(Unknown Source)
at com.google.android.gms.internal.zzaln.zzbw(Unknown Source)
at com.google.android.gms.internal.zzaln.zzcd(Unknown Source)
at com.google.android.gms.internal.zzaln$zza.zzce(Unknown Source)
at com.google.android.gms.internal.zzaln.zzbw(Unknown Source)
at com.google.android.gms.internal.zzaln.zzcd(Unknown Source)
at com.google.android.gms.internal.zzaln$zza.zzce(
I did search for this exception during runTransaction, but couldn't find any. Below is the code snippet where I get this exception:
dataSnapshot.getRef().runTransaction(new Transaction.Handler() {
#Override
public Transaction.Result doTransaction(MutableData mutableData) {
mutableData.child(order.getId() + "").setValue(order);
return Transaction.success(mutableData);
}

#Override
public void onComplete(DatabaseError databaseError, boolean isComplete, DataSnapshot dataSnapshot) {
logger.debug("isComplete - " + isComplete);
if(isComplete){
logger.debug("dataSnapshot - " + dataSnapshot);
callback.onSuccess(IConstants.USER_ORDER_SAVED);
} else {
logger.debug("databaseError - " + databaseError);
callback.onSuccess(IConstants.USER_ORDER_SAVE_FAILED);
}
}

});
I get this only with runTransaction. But setValue for a child and updateChildren are working good. Someone else faced with this scenario?
UPDATE:
The root cause i found is that, the Order POJO I was using has a sub-class which was not declared as static. I changed that, and everything is working as expected.

The appearance of dataSnapshot.getRef() in the code you posted is a clue that the code is running inside a listener callback. Let's say the listener is on location X. When you call dataSnapshot.getRef().runTransaction(), you are requesting the transaction on the value at location X. That value is the MutableData you get in the doTransaction() callback. In the doTransaction() callback, you are setting the value of a child of X, which is also a change to X itself. This causes the listener to fire again. I suspect that is the loop that is causing the stack overflow.
Also, this answer provides the details of how transactions are performed. It might be helpful.

For further readers... I had the problem that I had a method inside of my
POJO called getDBReference(), which was not static and returned the
DatabaseReference
to this POJO instance. Which, then in a transaction was falsely detected by reflection to "add" to the transaction and caused a StackOverFlow.
tl;dr
I forgot to annotate this method with #Exclude, that was the problem.

This occurs if u call FirebaseDatabase.getInstance() at several place . You should create a singleton instance of it and then use it throught out your project .
Example :
public class FirebaseUtils{
private static FirebaseDatabase mDatabase;
public static FirebaseDatabase getDatabase() {
if (mDatabase == null) {
mDatabase = FirebaseDatabase.getInstance();
}
return mDatabase;
} }
and get the database FirebaseUtils.getDatabase();

Related

android getting null pointer exception at java.util.Objects.requireNonNull(Objects.java:203)

I'm reading writing string arrays and displaying them in recycler view.
Before displaying them i'm reversing the order using
Collections.reverse(Arrays.asList(FilePathStrings));
Following is exception that I'm getting:
java.lang.NullPointerException
at java.util.Objects.requireNonNull(Objects.java:203)
at java.util.Arrays$ArrayList.<init>(Arrays.java:3826)
at java.util.Arrays.asList(Arrays.java:3813)
at com.example.soberapps.nightcamera.b.c.a(Unknown Source)
at android.support.v4.app.i.b(Unknown Source)
at android.support.v4.app.o.a(Unknown Source)
at android.support.v4.app.o.e(Unknown Source)
at android.support.v4.app.o.a(Unknown Source)
at android.support.v4.app.c.d(Unknown Source)
at android.support.v4.app.o.b(Unknown Source)
at android.support.v4.app.o.a(Unknown Source)
at android.support.v4.app.o.b(Unknown Source)
at android.support.v4.app.o.h(Unknown Source)
at android.support.v4.app.o$1.run(Unknown Source)
at android.os.Handler.handleCallback(Handler.java:751)
at android.os.Handler.dispatchMessage(Handler.java:95)
at androidx.test.espresso.base.Interrogator.a(Interrogator.java:19)
at androidx.test.espresso.base.UiControllerImpl.a(UiControllerImpl.java:164)
at androidx.test.espresso.base.UiControllerImpl.a(UiControllerImpl.java:156)
at androidx.test.espresso.base.UiControllerImpl.a(UiControllerImpl.java:34)
at androidx.test.espresso.action.MotionEvents.a(MotionEvents.java:75)
at androidx.test.espresso.action.MotionEvents.a(MotionEvents.java:50)
at androidx.test.espresso.action.Tap.c(Tap.java:8)
at androidx.test.espresso.action.Tap.a(Tap.java:18)
at androidx.test.espresso.action.Tap$1.b(Tap.java:3)
at androidx.test.espresso.action.GeneralClickAction.perform(GeneralClickAction.java:22)
at androidx.test.espresso.ViewInteraction$SingleExecutionViewAction.perform(ViewInteraction.java:9)
at androidx.test.espresso.ViewInteraction.a(ViewInteraction.java:78)
at androidx.test.espresso.ViewInteraction.a(ViewInteraction.java:94)
at androidx.test.espresso.ViewInteraction$1.call(ViewInteraction.java:3)
at java.util.concurrent.FutureTask.run(FutureTask.java:237)
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)
Error reporting crash
java.lang.NullPointerException: Attempt to invoke virtual method 'boolean java.lang.String.contains(java.lang.CharSequence)' on a null object reference
at android.os.Parcel.readException(Parcel.java:1689)
at android.os.Parcel.readException(Parcel.java:1636)
at android.app.ActivityManagerProxy.handleApplicationCrash(ActivityManagerProxy.java:5217)
at com.android.internal.os.RuntimeInit$UncaughtHandler.uncaughtException(RuntimeInit.java:97)
at java.lang.ThreadGroup.uncaughtException(ThreadGroup.java:1068)
at java.lang.ThreadGroup.uncaughtException(ThreadGroup.java:1063)
Arrays.asList(null) throws this exception. Your parameter (FilePathStrings) equals to null.

FirebaseFirestoreException: UNIMPLEMENTED: Unsupported FieldFilter value type: 9

I'm getting this weird exception from Firebase when I'm trying to query data. This error happens occasionally. Sometimes it works perfectly fine, but sometimes task.isSuccessful returns false. attrs is a String array field which have 2 items in Firestore. Is it happening because of using whereEqualTo on a String array? Or am I missing something else?
I'm using this link as a guide. I really want to understand why I'm getting this error. Thanks.
Code:
val queryOrderedAttributeList = attributeList
.sortedBy { cardAttribute -> cardAttribute.name }
.map { it.name.toLowerCase() }
val db = FirebaseFirestore.getInstance()
val collectionRef = db.collection("dbAllCards")
val query = collectionRef.whereEqualTo("attrs", queryOrderedAttributeList)
query.get().addOnCompleteListener { task ->
if (task.isSuccessful) {
task.result.forEach { document: DocumentSnapshot? ->
document?.id?.let { cardList.add(it) }
Log.e("firebase", "${document?.id} -> ${document?.data}")
}
} else {
Log.d("firebase", "Error getting documents: ", task.exception)
}
loadCardPathList(cardList)
}
Error getting documents:
com.google.firebase.firestore.FirebaseFirestoreException: UNIMPLEMENTED: Unsupported FieldFilter value type: 9
at com.google.android.gms.internal.zzevs.zzf(Unknown Source)
at com.google.android.gms.internal.zzenb.zza(Unknown Source)
at com.google.android.gms.internal.zzeoa.zza(Unknown Source)
at com.google.android.gms.internal.zzenf.zza(Unknown Source)
at com.google.android.gms.internal.zzett.zza(Unknown Source)
at com.google.android.gms.internal.zzett.zza(Unknown Source)
at com.google.android.gms.internal.zzetu.zzb(Unknown Source)
at com.google.android.gms.internal.zzeup.zzcg(Unknown Source)
at com.google.android.gms.internal.zzeth.zzcg(Unknown Source)
at com.google.android.gms.internal.zzevi.zzch(Unknown Source)
at com.google.android.gms.internal.zzfmg.zzch(Unknown Source)
at io.grpc.internal.zzac.zzdep(Unknown Source)
at io.grpc.internal.zzaq.run(Unknown Source)
at io.grpc.internal.zzeo.run(Unknown Source)
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:428)
at java.util.concurrent.FutureTask.run(FutureTask.java:237)
at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:272)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1133)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:607)
at com.google.android.gms.internal.zzeuu$zza.run(Unknown Source)
at java.lang.Thread.run(Thread.java:761)
Caused by: com.google.adroid.gms.internal.zzfk: UNIMPLEMENTED: nsupported ieldFilter value ype: 9
at com.google.android.gms.internal.zzfof.zzddl(Unknown Source)
at com.google.android.gms.internal.zzevs.zzf(Unknown Source)
at com.google.android.gms.internal.zzenb.zza(Unknown Source)
at com.google.android.gms.internal.zzeoa.zza(Unknown Source)
at com.google.android.gms.internal.zzenf.zza(Unknown Source)
at com.google.android.gms.internal.zzett.zza(Unknown Source)
at com.google.android.gms.internal.zzett.zza(Unknown Source)
at com.google.android.gms.internal.zzetu.zzb(Unknown Source)
at com.google.android.gms.internal.zzeup.zzcg(Unknown Source)
at com.google.android.gms.internal.zzeth.zzcg(Unknown Source)
at com.google.android.gms.internal.zzevi.zzch(Unknown Source)
at com.google.android.gms.internal.zzfmg.zzch(Unknown Source)
at io.grpc.internal.zzac.zzdep(Unknown Source)
at io.grpc.internal.zzaq.run(Unknown Source)
at io.grpc.internal.zzeo.run(Unknown Source)
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:428)
at java.util.concurrent.FutureTask.run(FutureTask.java:237)
at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:272)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1133)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:607)
at com.google.android.gms.internal.zzeuu$zza.run(Unknown Source)
at java.lang.Thread.run(Thread.java:761)
Update: Since my original answer, Cloud Firestore has added support for these kinds of queries. You should not see this error message anymore.
You can now query arrays, as well as do array-contains queries for individual array elements.
[Firebaser here] You have diagnosed this correctly, the error message you are seeing is because you are doing a whereEqualTo query against an array value. You would get a similar error message if you passed in a Map<> value to the same clause.
The first thing we will do is improve this error message, and then possibly add support for these queries in the future.

Get image from Firebase without uploading it via phone

Its my first time with Firebase
I want to create a option with "special offers"
And its will work like i will upload via browser the image and my application will download it. I create some of code, but when i try to get image i just got
Some facts:
In firebase i have sub folder offer
my photo is named Capture.png
E/StorageException: StorageException has occurred.
An unknown error occurred, please check the HTTP result code and inner exception for server response.
Code: -13000 HttpResult: 0
E/StorageException: /image/png (No such file or directory)
java.io.FileNotFoundException: /image/png (No such file or directory)
at java.io.FileInputStream.open(Native Method)
at java.io.FileInputStream.<init>(FileInputStream.java:146)
at java.io.FileInputStream.<init>(FileInputStream.java:99)
at android.content.ContentResolver.openInputStream(ContentResolver.java:702)
at com.google.firebase.storage.UploadTask.<init>(Unknown Source)
at com.google.firebase.storage.StorageReference.putFile(Unknown Source)
at com.example.andrzej.forexapp.activities.fragments.SettingsFragment.configureSettingsMenus(SettingsFragment.java:147)
at com.example.andrzej.forexapp.activities.fragments.SettingsFragment.onCreateView(SettingsFragment.java:82)
at android.support.v4.app.Fragment.performCreateView(Fragment.java:2189)
at android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:1299)
at android.support.v4.app.FragmentManagerImpl.moveFragmentToExpectedState(FragmentManager.java:1528)
at android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:1595)
at android.support.v4.app.BackStackRecord.executeOps(BackStackRecord.java:757)
at android.support.v4.app.FragmentManagerImpl.executeOps(FragmentManager.java:2355)
at android.support.v4.app.FragmentManagerImpl.executeOpsTogether(FragmentManager.java:2146)
at android.support.v4.app.FragmentManagerImpl.optimizeAndExecuteOps(FragmentManager.java:2098)
at android.support.v4.app.FragmentManagerImpl.execPendingActions(FragmentManager.java:2008)
at android.support.v4.app.FragmentManagerImpl$1.run(FragmentManager.java:710)
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:6119)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:886)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:776)
E/StorageException: StorageException has occurred.
And here is my code
private StorageReference storageReference;
storageReference = FirebaseStorage.getInstance().getReference();
imageSettings.setVisibility(View.VISIBLE);
StorageReference islandRef = storageReference.child("offer/Capture.PNG");
Uri file = Uri.fromFile(new File("image/png"));
islandRef.putFile(file).addOnSuccessListener(new OnSuccessListener<UploadTask.TaskSnapshot>() {
#Override
public void onSuccess(UploadTask.TaskSnapshot taskSnapshot) {
Uri downloadFile = taskSnapshot.getDownloadUrl();
Picasso.with(getContext()).load(downloadFile).fit().centerCrop().into(imageSettings);
}
});
Any help approciate
EDIT:
I try to get image by code like:
Glide.with(this)
.using(new FirebaseImageLoader())
.load(storageReference)
.into(imageSettings);
but i have an exception:
E/StorageException: null
android.os.RemoteException
at com.google.android.gms.internal.zzbre.<init>(Unknown Source)
at com.google.android.gms.internal.zzbre.zzj(Unknown Source)
at com.google.firebase.storage.StorageReference.zzaaN(Unknown Source)
at com.google.firebase.storage.StreamDownloadTask.run(Unknown Source)
at com.google.firebase.storage.StorageTask$8.run(Unknown Source)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1133)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:607)
at java.lang.Thread.run(Thread.java:761)
I try all and i got errors:
03-08 09:37:17.004 18382-19615/com.example.andrzej.forexapp E/NetworkRqFactoryProxy: NetworkRequestFactoryProxy failed with a RemoteException:
com.google.android.gms.dynamite.DynamiteModule$zza: No acceptable module found. Local version is 0 and remote version is 0.
at com.google.android.gms.dynamite.DynamiteModule.zza(Unknown Source)
at com.google.android.gms.dynamite.DynamiteModule.zza(Unknown Source)
at com.google.android.gms.internal.zzbre.<init>(Unknown Source)
at com.google.android.gms.internal.zzbre.zzj(Unknown Source)
at com.google.firebase.storage.StorageReference.zzaaN(Unknown Source)
at com.google.firebase.storage.StreamDownloadTask.run(Unknown Source)
at com.google.firebase.storage.StorageTask$8.run(Unknown Source)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1133)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:607)
at java.lang.Thread.run(Thread.java:761)
03-08 09:37:17.005 18382-19615/com.example.andrzej.forexapp E/StreamDownloadTask: Unable to create firebase storage network request.
android.os.RemoteException
at com.google.android.gms.internal.zzbre.<init>(Unknown Source)
at com.google.android.gms.internal.zzbre.zzj(Unknown Source)
at com.google.firebase.storage.StorageReference.zzaaN(Unknown Source)
at com.google.firebase.storage.StreamDownloadTask.run(Unknown Source)
at com.google.firebase.storage.StorageTask$8.run(Unknown Source)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1133)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:607)
at java.lang.Thread.run(Thread.java:761)
03-08 09:37:17.005 18382-19615/com.example.andrzej.forexapp E/StorageException: StorageException has occurred.
An unknown error occurred, please check the HTTP result code and inner exception for server response.
Code: -13000 HttpResult: 0
03-08 09:37:17.005 18382-19615/com.example.andrzej.forexapp E/StorageException: null
android.os.RemoteException
at com.google.android.gms.internal.zzbre.<init>(Unknown Source)
at com.google.android.gms.internal.zzbre.zzj(Unknown Source)
at com.google.firebase.storage.StorageReference.zzaaN(Unknown Source)
at com.google.firebase.storage.StreamDownloadTask.run(Unknown Source)
at com.google.firebase.storage.StorageTask$8.run(Unknown Source)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1133)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:607)
at java.lang.Thread.run(Thread.java:761)
03-08 09:37:17.005 18382-19615/com.example.andrzej.forexapp E/StorageException: StorageException has occurred.
An unknown error occurred, please check the HTTP result code and inner exception for server response.
Code: -13000 HttpResult: 0
03-08 09:37:17.005 18382-19615/com.example.andrzej.forexapp E/StorageException: null
android.os.RemoteException
at com.google.android.gms.internal.zzbre.<init>(Unknown Source)
at com.google.android.gms.internal.zzbre.zzj(Unknown Source)
at com.google.firebase.storage.StorageReference.zzaaN(Unknown Source)
at com.google.firebase.storage.StreamDownloadTask.run(Unknown Source)
at com.google.firebase.storage.StorageTask$8.run(Unknown Source)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1133)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:607)
at java.lang.Thread.run(Thread.java:761)
03-08 09:37:17.644 18382-18492/com.example.andrzej.forexapp E/EGL_emulation: tid 18492: eglSurfaceAttrib(1174): error 0x3009 (EGL_BAD_MATCH)
As per your code snippet you are passing main storage reference(i.e. storageReference ) not the image file reference (i.e.islandRef)
StorageReference storageReference =
FirebaseStorage.getInstance().getReference();
StorageReference islandRef =
storageReference.child("offer/Capture.PNG");
Glide.with(this)
.using(new FirebaseImageLoader())
.load(islandRef)
.into(imageSettings);

I made a chatting app which is continuosly showing errors

E/AndroidRuntime: FATAL EXCEPTION: main
Process: com.google.firebase.udacity.friendlychat, PID: 28266
com.google.firebase.database.DatabaseException: Class com.google.firebase.udacity.friendlychat.FriendlyMessage 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.google.firebase.udacity.friendlychat.MainActivity$6.onChildAdded(MainActivity.java:290)
at com.google.android.gms.internal.zzblz.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:751)
at android.os.Handler.dispatchMessage(Handler.java:95)
at android.os.Looper.loop(Looper.java:154)
at android.app.ActivityThread.main(ActivityThread.java:6688)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1468)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1358)
As your error message says:
com.google.firebase.udacity.friendlychat.FriendlyMessage is missing a constructor with no arguments
So you must be missing a default constructor (constructor with no arguments) in your FriendlyMessage class

Uncaught exception in Firebase runloop (3.0.0) related to persistence and queries

I'm struggling with this exception for a while already. A relevant thread on the firebase group is kind of dead https://groups.google.com/forum/#!topic/firebase-talk/iy0762S3KsU, also two related on SO are unanswered: Uncaught exception in Firebase runloop (3.0.0) and Uncaught exception in Firebase runloop (3.0.0). Please report to support#firebase.com
The workaround saying to switch off database persistence works, but it's not unacceptable for apps which require offline capability.
I've prepared a minimal activity example which reproduces the exception in my environment. It all comes down to reading the database with queries. It's enough to launch and terminate ("terminate" from Android Studio, not just quit) the activity 3 times (weird) and on the 3rd launch it will crash with the following spectacular series of exceptions (the more queries queued the more exceptions i think):
07-05 18:47:10.132 20291-20291/com.mypackage D/ChimeraFileApk: Classloading successful. Optimized code found.
07-05 18:47:10.154 20291-20381/com.mypackage E/RunLoop: Uncaught exception in Firebase runloop (3.0.0). Please report to support#firebase.com
java.lang.AssertionError: hardAssert failed:
at com.google.android.gms.internal.zzaiv.zzb(Unknown Source)
at com.google.android.gms.internal.zzaiv.zzaN(Unknown Source)
at com.google.android.gms.internal.zzagh.zzb(Unknown Source)
at com.google.android.gms.internal.zzagh.<init>(Unknown Source)
at com.google.android.gms.internal.zzaga.<init>(Unknown Source)
at com.google.android.gms.internal.zzaga.<init>(Unknown Source)
at com.google.android.gms.internal.zzadp.zza(Unknown Source)
at com.google.android.gms.internal.zzaeu.zzic(Unknown Source)
at com.google.android.gms.internal.zzafc.zzRy(Unknown Source)
at com.google.android.gms.internal.zzafc.zza(Unknown Source)
at com.google.android.gms.internal.zzafc$1.run(Unknown Source)
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:423)
at java.util.concurrent.FutureTask.run(FutureTask.java:237)
at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:269)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1113)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:588)
at java.lang.Thread.run(Thread.java:818)
07-05 18:47:10.154 20291-20291/com.mypackage D/AndroidRuntime: Shutting down VM
07-05 18:47:10.155 20291-20291/com.mypackage E/AndroidRuntime: FATAL EXCEPTION: main
Process: com.mypackage, PID: 20291
java.lang.RuntimeException: Uncaught exception in Firebase runloop (3.0.0). Please report to support#firebase.com
at com.google.android.gms.internal.zzadp$1$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:148)
at android.app.ActivityThread.main(ActivityThread.java:5417)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:726)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616)
Caused by: java.lang.AssertionError: hardAssert failed:
at com.google.android.gms.internal.zzaiv.zzb(Unknown Source)
at com.google.android.gms.internal.zzaiv.zzaN(Unknown Source)
at com.google.android.gms.internal.zzagh.zzb(Unknown Source)
at com.google.android.gms.internal.zzagh.<init>(Unknown Source)
at com.google.android.gms.internal.zzaga.<init>(Unknown Source)
at com.google.android.gms.internal.zzaga.<init>(Unknown Source)
at com.google.android.gms.internal.zzadp.zza(Unknown Source)
at com.google.android.gms.internal.zzaeu.zzic(Unknown Source)
at com.google.android.gms.internal.zzafc.zzRy(Unknown Source)
at com.google.android.gms.internal.zzafc.zza(Unknown Source)
at com.google.android.gms.internal.zzafc$1.run(Unknown Source)
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:423)
at java.util.concurrent.FutureTask.run(FutureTask.java:237)
at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:269)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1113)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:588)
at java.lang.Thread.run(Thread.java:818)
07-05 18:47:10.165 20291-20381/com.mypackage E/RunLoop: Uncaught exception in Firebase runloop (3.0.0). Please report to support#firebase.com
java.lang.NullPointerException: Attempt to invoke virtual method 'java.util.List com.google.android.gms.internal.zzafj.zzg(com.google.android.gms.internal.zzaew)' on a null object reference
at com.google.android.gms.internal.zzafc.zzf(Unknown Source)
at com.google.firebase.database.Query$3.run(Unknown Source)
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:423)
at java.util.concurrent.FutureTask.run(FutureTask.java:237)
at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:269)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1113)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:588)
at java.lang.Thread.run(Thread.java:818)
07-05 18:47:10.166 20291-20381/com.mypackage E/RunLoop: Uncaught exception in Firebase runloop (3.0.0). Please report to support#firebase.com
java.lang.NullPointerException: Attempt to invoke virtual method 'java.util.List com.google.android.gms.internal.zzafj.zzg(com.google.android.gms.internal.zzaew)' on a null object reference
at com.google.android.gms.internal.zzafc.zzf(Unknown Source)
at com.google.firebase.database.Query$3.run(Unknown Source)
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:423)
at java.util.concurrent.FutureTask.run(FutureTask.java:237)
at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:269)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1113)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:588)
at java.lang.Thread.run(Thread.java:818)
07-05 18:47:10.173 20291-20381/com.mypackage E/RunLoop: Uncaught exception in Firebase runloop (3.0.0). Please report to support#firebase.com
java.lang.NullPointerException: Attempt to invoke virtual method 'void com.google.android.gms.internal.zzafg.zzg(com.google.android.gms.internal.zzafa, com.google.android.gms.internal.zzahu)' on a null object reference
at com.google.android.gms.internal.zzafc.zzb(Unknown Source)
at com.google.android.gms.internal.zzafc.zza(Unknown Source)
at com.google.android.gms.internal.zzafc.zzaO(Unknown Source)
at com.google.firebase.database.connection.idl.IPersistentConnectionImpl$3.zzaO(Unknown Source)
at com.google.firebase.database.connection.idl.zzi$zza.onTransact(Unknown Source)
at android.os.Binder.transact(Binder.java:387)
at alx.a(:com.google.android.gms.DynamiteModulesC:196)
at amb.a(:com.google.android.gms.DynamiteModulesC:330)
at akh.a(:com.google.android.gms.DynamiteModulesC:3591)
at amf.a(:com.google.android.gms.DynamiteModulesC:386)
at aln.onTransact(:com.google.android.gms.DynamiteModulesC:50)
at android.os.Binder.transact(Binder.java:387)
at com.google.firebase.database.connection.idl.zzf$zza$zza.zzhT(Unknown Source)
at com.google.firebase.database.connection.idl.IPersistentConnectionImpl$5$1.zzhT(Unknown Source)
at com.google.android.gms.internal.zzaeu$1$1.zzhT(Unknown Source)
at com.google.android.gms.internal.zzadn$1.onFailure(Unknown Source)
at com.google.android.gms.tasks.zzd$1.run(Unknown Source)
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:423)
at java.util.concurrent.FutureTask.run(FutureTask.java:237)
at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:269)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1113)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:588)
at java.lang.Thread.run(Thread.java:818)
07-05 18:47:11.745 20291-20291/com.mypackage I/Process: Sending signal. PID: 20291 SIG: 9
The crash is on the first attempt to read after getting the reference to the database and setting persistence is done.
Here's the activity:
public class TestRunloopException extends AppCompatActivity {
private static final String TAG = "test";
private Handler mHandler = new Handler();
Runnable mReadScoresRunnable = new Runnable() {
#Override
public void run() {
readScores();
mHandler.postDelayed(mReadScoresRunnable, 5000);
}
};
#Override
protected void onStart() {
super.onStart();
mHandler.postDelayed(mReadScoresRunnable, 3000);
}
void readScores() {
DatabaseReference scoresRef = getDatabase().getReference("scores");
//it occurs even with a single query..
//scoresRef.startAt(51).limitToFirst(3).addListenerForSingleValueEvent(new MyValueListener());
scoresRef.endAt(50).limitToLast(4).addListenerForSingleValueEvent(new MyValueListener());
}
public static class MyValueListener implements ValueEventListener {
#Override
public void onDataChange(DataSnapshot data) {
Log.d(TAG, "onDataChange: " + data.getValue());
}
#Override
public void onCancelled(DatabaseError error) {
Log.d(TAG, "onCancelled: " + error.getMessage());
}
}
// access-wrapper, set persistence only once
private static FirebaseDatabase mDatabase;
public static FirebaseDatabase getDatabase() {
if (mDatabase == null) {
mDatabase = FirebaseDatabase.getInstance();
mDatabase.setPersistenceEnabled(true);
}
return mDatabase;
}
}
The "scores" node has no particular security settings: "scores": { ".read": true, ".write": true } ...
Tested with firebase-*:9.0.2, but the bug has been also observed with 9.2.0.
How to avoid the crash while using multiple queries on the same reference/node and of course having persistence?
The only solution that worked for me is calling the Event Listener twice back to back.
scoresRef.endAt(50).limitToLast(4).addListenerForSingleValueEvent(new MyValueListener());
scoresRef.endAt(50).limitToLast(4).addListenerForSingleValueEvent(new MyValueListener());
I had the same problem, i just fixed updating a version of firebase-core and firebase-database on build.gradle (app module)
dependencies {
...
implementation 'com.google.firebase:firebase-core:17.1.0'
implementation 'com.google.firebase:firebase-database:19.0.0'
}
you can check if you have i current version on https://firebase.google.com/support/release-notes/android

Categories

Resources