1

I have an app with a lot of activities in it and some of them are connected to a Firebase database. Recently, I have started to experience crashes when I go to both the activities that have the Firebase call and the activities before. After the app crashes, it restarts and then it works as it should. So only after I install it through USB it does that. Logcat shows this when the crash happens:

1-17 21:47:38.030 10998-11021/packagename D/FA: Logging event (FE): app_exception(_ae), Bundle[{firebase_event_origin(_o)=crash, timestamp=1516222057770, fatal=1}]
01-17 21:47:39.291 24162-10793/? V/FA-SVC: Logging event: origin=crash,name=app_exception(_ae),params=Bundle[{firebase_event_origin(_o)=crash, timestamp=1516222057770, fatal=1}]
01-17 21:47:39.321 24162-10793/? V/FA-SVC: Saving event, name, data size: app_exception(_ae), 51
01-17 21:47:39.321 24162-10793/? V/FA-SVC: Event recorded: Event{appId='packagename', name='app_exception(_ae)', params=Bundle[{firebase_event_origin(_o)=crash, timestamp=1516222057770, fatal=1}]}
01-17 21:47:39.331 24162-10793/? V/FA-SVC: Upload scheduled in approximately ms: 2620327
01-17 21:47:39.471 24162-10793/? V/FA-SVC: Scheduling upload with GcmTaskService
01-17 21:47:39.471 24162-10793/? V/FA-SVC: Scheduling task with Gcm. Time2620327
01-17 21:47:39.702 24162-10793/? V/FA-SVC: Background event processing time, ms: 412

The part that caught my attention was this:

Logging event (FE): app_exception(_ae), bundle[{firebase_event_origin(_o)=crash

However, I don't know what to do with it... It's obvious that it is from Firebase, but from where exactly?

The Java file that contains the Firebase script is given as below:

package packagename;

import android.os.Bundle;
import android.support.design.widget.FloatingActionButton;
import android.support.v7.app.AppCompatActivity;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.support.v7.widget.Toolbar;
import android.view.View;
import android.widget.ImageView;
import android.widget.TextView;

import com.bumptech.glide.Glide;
import com.firebase.ui.database.FirebaseRecyclerAdapter;
import com.firebase.ui.storage.images.FirebaseImageLoader;
import com.google.firebase.database.DatabaseReference;
import com.google.firebase.database.FirebaseDatabase;
import com.google.firebase.storage.FirebaseStorage;
import com.google.firebase.storage.StorageReference;

import packagename.model.Post;
import packagename.utils.Constants;
import packagename.utils.Utils;


public class Evenimente extends AppCompatActivity {

  private RecyclerView mPostRV;
  private FirebaseRecyclerAdapter < Post, PostViewHolder > mPostAdapter;
  private DatabaseReference mPostRef;
  static boolean calledAlready = false;

  @Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    if (!calledAlready) {
      FirebaseDatabase.getInstance().setPersistenceEnabled(true);
      calledAlready = true;
    }
    setContentView(R.layout.activity_evenimente);

    Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
    setSupportActionBar(toolbar);
    getSupportActionBar().setDisplayShowTitleEnabled(false);
    if (getSupportActionBar() != null) {
      getSupportActionBar().setDisplayHomeAsUpEnabled(true);
      getSupportActionBar().setDisplayShowHomeEnabled(true);
    }

    initialiseScreen();
  }
  public boolean onSupportNavigateUp() {
    onBackPressed();
    return true;
  }


  private void sendPostToFirebase() {
    Post post = new Post();
    String UID = Utils.getUID();

    post.setUID(UID);
    post.setHeadline("Nume eveniment");
    post.setZiua(25);
    post.setOra("10:00");
    post.setLuna("IAN");
    post.setCategoria("Teatru");
    post.setOrganizator("Casa de Cultura");
    post.setStrada("Strada:");
    post.setLocalitatea("Undeva");

    /*  post.setNumLikes(0);*/
    post.setImageUrl("gs://packagename1234.appspot.com/teatru.jpg");
    mPostRef.child(UID).setValue(post);
  }

  private void initialiseScreen() {
    mPostRV = (RecyclerView) findViewById(R.id.post_rv);
    mPostRV.setLayoutManager(new LinearLayoutManager(Evenimente.this));
    mPostRef = FirebaseDatabase.getInstance().getReference(Constants.POSTS);
    mPostRef.keepSynced(true);
    setupAdaptater();
    mPostRV.setAdapter(mPostAdapter);
  }

  private void setupAdaptater() {
    mPostAdapter = new FirebaseRecyclerAdapter < Post, PostViewHolder > (
      Post.class,
      R.layout.item_layout_evenimente,
      PostViewHolder.class,
      mPostRef
    ) {
      @Override
      protected void populateViewHolder(PostViewHolder viewHolder, final Post model, int position) {
        StorageReference storageReference = FirebaseStorage.getInstance().getReferenceFromUrl(model.getImageUrl());
        Glide.with(Evenimente.this)
          .using(new FirebaseImageLoader())
          .load(storageReference)
          .into(viewHolder.postIV);



        viewHolder.setHeadline(model.getHeadline());
        viewHolder.setZiua(model.getZiua());
        viewHolder.setLuna(model.getLuna());
        viewHolder.setOra(model.getOra());
        viewHolder.setOrganizator(model.getOrganizator());
        viewHolder.setCategoria(model.getCategoria());
        viewHolder.setStrada(model.getStrada());

        viewHolder.setLocalitatea(model.getLocalitatea());


      }
    };
  }

  public static class PostViewHolder extends RecyclerView.ViewHolder {
    public ImageView postIV;
    public TextView postHeadline;
    public TextView postZiua;
    public TextView postLuna;
    public TextView postOra;
    public TextView postOrganizator;
    public TextView postCategoria;
    public TextView postStrada;
    public TextView postNumar_strada;
    public TextView postLocalitatea;

    public PostViewHolder(View itemView) {
      super(itemView);
      postIV = (ImageView) itemView.findViewById(R.id.post_iv);
      postHeadline = (TextView) itemView.findViewById(R.id.headline_event);
      postZiua = (TextView) itemView.findViewById(R.id.text_ziua);
      postLuna = (TextView) itemView.findViewById(R.id.text_luna);
      postOra = (TextView) itemView.findViewById(R.id.text_ora);
      postOrganizator = (TextView) itemView.findViewById(R.id.text_organizator);
      postCategoria = (TextView) itemView.findViewById(R.id.text_categoria);
      postStrada = (TextView) itemView.findViewById(R.id.text_strada);
      postLocalitatea = (TextView) itemView.findViewById(R.id.text_localitatea);
    }

    public void setPostImage(String url) {
      StorageReference storageReference = FirebaseStorage.getInstance().getReferenceFromUrl(url);
    }

    public void setHeadline(String headline) {
      postHeadline.setText(String.valueOf(headline));
    }

    public void setZiua(long ziua) {
      postZiua.setText(String.valueOf(ziua));
    }

    public void setLuna(String luna) {
      postLuna.setText(String.valueOf(luna));
    }

    public void setOra(String ora) {
      postOra.setText(String.valueOf(ora));
    }

    public void setOrganizator(String organizator) {
      postOrganizator.setText(String.valueOf(organizator));
    }

    public void setCategoria(String categoria) {
      postCategoria.setText(String.valueOf(categoria));
    }

    public void setStrada(String strada) {
      postStrada.setText(String.valueOf(strada));
    }

    public void setLocalitatea(String localitatea) {
      postLocalitatea.setText(String.valueOf(localitatea));
    }

  }
}

After reading about this error here, I saw that some suggest that it might be a problem with the length of the characters, but I can't figure out if this is my problem. I don't go over 40 characters in my database.

The configuration of the database on Firebase looks like in the picture below: enter image description here

The error is a vague one and I don't really know where to start. Can anyone help me? Thank you!

CuriousPaul
  • 449
  • 8
  • 20

1 Answers1

1

The logs you're showing aren't because your app is crashing at that moment. That's Google Analytics for Firebase logging the fact that your app previously crashed, and it's generating an analytics event for that. You can also see that these are just verbose level severity messages. A true crash will be accompanied by messages with error level severity messages, and typically a Java stack trace to go along it that.

Doug Stevenson
  • 297,357
  • 32
  • 422
  • 441
  • That's the only thing I get in Logcat when the app crashes... But you are right, now I can see that I have it with details in the Firebase crash logging. In there, I have Error inflating class ImageView, which is solvable. Thank you so much for indicating this. I would have never guessed, although it looks very obvious. – CuriousPaul Jan 17 '18 at 21:41