I'm having a problem with my firebase project.
I followed the steps on firebase GitHub documentation, but I got this exception
java.lang.RuntimeException: java.lang.NoSuchMethodException: <init>
[class android.view.View]
this is a ViewHolder class which is not an inner class.
public class ProductViewHolder extends RecyclerView.ViewHolder{
public View mView;
public ImageView img;
public TextView title;
public TextView price;
public RatingBar stars;
ProductViewHolder(View itemView) {
    super(itemView);
    mView = itemView;
    img = (ImageView) itemView.findViewById(R.id.productImg);
    title = (TextView) itemView.findViewById(R.id.txtTitle);
    price = (TextView) itemView.findViewById(R.id.txtPrice);
    stars = (RatingBar) itemView.findViewById(R.id.ratingBar);
    }
}
and this is the firebase related code
@Override
protected void onStart() {
    super.onStart();
    // Recycler adapter
    FirebaseRecyclerAdapter<Product, ProductViewHolder> adapter =
            new FirebaseRecyclerAdapter<Product, ProductViewHolder>(
                    Product.class,
                    R.layout.product_list_item,
                    ProductViewHolder.class,
                    firebaseRef.child("product")) {
                @Override
                protected void populateViewHolder(ProductViewHolder productViewHolder, Product product, int i) {
                    Picasso.with(ShopsApp.getLyShopsAppContext())
                            .load(product.getImgUrl())
                            .placeholder(R.drawable.none)
                            .into(productViewHolder.img);
                    productViewHolder.title.setText(product.getTitle());
                    productViewHolder.price.setText(product.getPrice());
                    productViewHolder.stars.setRating(4.0f);
                }
            };
    recyclerView1.setAdapter(adapter);
I'm using firebaseRecyclerView to populate data model,
and the viewHolder class is not inner class of my activity
Note: the exception occurs when the activity that contains the recyclerView starts.
Most likely your custom ViewHolder subclass is:
public MyViewHolder(View itemView) {... } OR public static class MyViewHolder.If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With