Home > database >  Firebase Recycler Adapter giving an error
Firebase Recycler Adapter giving an error

Time:03-04

Am trying to populate a recyclerView with some cartItems(model class) but the app keeps crashing. The error message I got from the logs:

2022-03-03 10:00:11.060 3810-4183/? E/FirebaseInstanceId: Failed to get FIS auth token
java.util.concurrent.ExecutionException: adly: Firebase Installations Service is unavailable. Please try again later.
    at ljb.X(PG:5)
    at ljb.C(PG:7)
    at aecs.g(PG:14)
    at adlk.a(PG:14)
    at mdx.run(PG:19)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1162)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:636)
    at lsi.run(PG:2)
    at java.lang.Thread.run(Thread.java:764)
 Caused by: adly: Firebase Installations Service is unavailable. Please try again later.
    at admj.b(PG:54)
    at adlv.run(PG:15)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1162)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:636)
    at java.lang.Thread.run(Thread.java:764) 

2022-03-03 10:00:12.662 3810-4182/? E/FirebaseInstanceId: Topic sync or token retrieval failed on hard failure exceptions: FIS_AUTH_ERROR. Won't retry the operation.

My Fireebase recycler options and adapter code:

Query query = FirebaseDatabase.getInstance()
                .getReference()
                .child("Cart List")
                .child("User View")
                .child(Prevalent.currentOnlineUsr.getPhone())
                .child("Products")
                .limitToLast(10);

        FirebaseRecyclerOptions<CartItem> options =
                new FirebaseRecyclerOptions.Builder<CartItem>()
                        .setQuery(query, CartItem.class).build();

        FirebaseRecyclerAdapter<CartItem, CartViewHolder> adapter =
                new FirebaseRecyclerAdapter<CartItem, CartViewHolder>(options) {
                    @Override
                    protected void onBindViewHolder(@NonNull CartViewHolder holder, int position, @NonNull CartItem model) {
                        holder.txtProductName.setText(model.getPname());
                        holder.txtProductPrice.setText(model.getPrice());
                        holder.txtProductQuantity.setText(model.getQuantity());

                    }

                    @NonNull
                    @Override
                    public CartViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
                        View view = LayoutInflater.from(parent.getContext())
                                .inflate(R.layout.cart_item_layout, parent,false);
                        return new CartViewHolder(view);
                    }
                };
        cart_Recycler.setAdapter(adapter);
        adapter.startListening();

I don't know if there is need for the ViewHolder class or the model class. What's really puzzling me is am using the same method on the home activity to populate the home recycler and it works without any errors.

CodePudding user response:

You got an error Firebase Installation Service not working.
It turns out that new versions of Firebase SDKs depend on a new internal infrastructure service, called FIS (the Firebase Installations Service) for targeting identifiers ("FIDs" or "Instance-IDs").
If you are using API key restrictions for the API keys you use in your application, you will have to extend those restrictions to allow usage with the new Firebase Installations Service at firebaseinstallations.googleapis.com.

To allow your API key in question to be used with the new Firebase Installations API:

  1. go to the Google Cloud Console
  2. choose the relevant project (i.e. the project you use for your application)
  3. open the menu and go to APIs & Services -> Credentials
  4. click Edit API key for the API key in question
  5. scroll down to API restrictions
  6. from the dropdown, choose Firebase Installations API
    click Save
  7. wait a couple of minutes for Google servers to update and retry...

CodePudding user response:

Could try creating a new project in Android Studio, and try everything from zero, in particular your project files that are needed for you to figure out what's the problem. Create a new database in Firebase, try switching regions this time (I don't recommend Europe because of bucket errors that I had in multiple occasions...)

  • Related