What causing this exception java.lang.RuntimeException: java.lang.NoSuchMethodException: <init> [class android.view.View]

Abdalltif Basher

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.

Frank van Puffelen

Most likely your custom ViewHolder subclass is:

  • missing a constructor public MyViewHolder(View itemView) {... } OR
  • the class is defined inside another class, in which case you need to mark it as static public static class MyViewHolder.

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

java.lang.RuntimeException,Caused by: android.view.InflateException

From Dev

java.lang.RuntimeException: android.view.InflateException: Binary XML file line #10: Error inflating class

From Dev

java.lang.RuntimeException: java.lang.NoSuchMethodException: Hadoop mapreduce

From Dev

java.lang.RuntimeException: java.lang.NoSuchMethodException: Hadoop mapreduce

From Dev

Caused by: java.lang.NoSuchMethodException: <init> [class android.content.Context, interface android.util.AttributeSet]

From Dev

Android custom-view - java.lang.RuntimeException android.view.InflateException

From Dev

java.lang.NoSuchMethodException: AffirmativeBased.<init>()

From Dev

java.lang.NoSuchMethodException: <Class>.<init>(java.lang.String) when copying custom Transformer

From Dev

What might be the reason for this exception? java.lang.RuntimeException: InputChannel is not initialized

From Dev

java.lang.RuntimeException: Unable to start activity ComponentInfo:android.view.InflateException

From Dev

java.lang.RuntimeException: view android.widget.TextView being added, but it already has a parent

From Dev

java.lang.RuntimeException: Unable to start activity ComponentInfo:android.view.InflateException

From Dev

Exception while starting up the server : java.lang.NoSuchMethodException: org.springframework.security.authentication.ProviderManager.<init>()

From Dev

android java.lang.AssertionError: java.lang.NoSuchMethodException - Proguard

From Dev

Java - java.lang.NoSuchMethodException

From Dev

Recycler View Fatal Exception: java.lang.ArrayIndexOutOfBoundsException

From Dev

Exception java.lang.NoClassDefFoundError for android.support.v4.view.ViewCompatGingerbread

From Dev

Custom Fonts in Android: java.lang.RuntimeException

From Dev

Android [LocationManager] requestLocationUpdates(), java.lang.RuntimeException

From Dev

Android app java.lang.RuntimeException error

From Dev

Android PreferenceFragment : java.lang.RuntimeException

From Dev

java.lang.RuntimeException: Android Runtime error

From Dev

Android Boilepipe - java.lang.RuntimeException

From Dev

Android RuntimeException caused by java.lang.ClassNotFoundException

From Dev

No default constructor found; nested exception is java.lang.NoSuchMethodException

From Java

java.lang.NoSuchMethodException for onCreate

From Dev

ProGuard java.lang.NoSuchMethodException

From Dev

java.lang.NoSuchMethodException for onCreate

From Dev

Error: java.lang.NoSuchMethodException: java.lang.Long.<init>() in spring MVC

Related Related

  1. 1

    java.lang.RuntimeException,Caused by: android.view.InflateException

  2. 2

    java.lang.RuntimeException: android.view.InflateException: Binary XML file line #10: Error inflating class

  3. 3

    java.lang.RuntimeException: java.lang.NoSuchMethodException: Hadoop mapreduce

  4. 4

    java.lang.RuntimeException: java.lang.NoSuchMethodException: Hadoop mapreduce

  5. 5

    Caused by: java.lang.NoSuchMethodException: <init> [class android.content.Context, interface android.util.AttributeSet]

  6. 6

    Android custom-view - java.lang.RuntimeException android.view.InflateException

  7. 7

    java.lang.NoSuchMethodException: AffirmativeBased.<init>()

  8. 8

    java.lang.NoSuchMethodException: <Class>.<init>(java.lang.String) when copying custom Transformer

  9. 9

    What might be the reason for this exception? java.lang.RuntimeException: InputChannel is not initialized

  10. 10

    java.lang.RuntimeException: Unable to start activity ComponentInfo:android.view.InflateException

  11. 11

    java.lang.RuntimeException: view android.widget.TextView being added, but it already has a parent

  12. 12

    java.lang.RuntimeException: Unable to start activity ComponentInfo:android.view.InflateException

  13. 13

    Exception while starting up the server : java.lang.NoSuchMethodException: org.springframework.security.authentication.ProviderManager.<init>()

  14. 14

    android java.lang.AssertionError: java.lang.NoSuchMethodException - Proguard

  15. 15

    Java - java.lang.NoSuchMethodException

  16. 16

    Recycler View Fatal Exception: java.lang.ArrayIndexOutOfBoundsException

  17. 17

    Exception java.lang.NoClassDefFoundError for android.support.v4.view.ViewCompatGingerbread

  18. 18

    Custom Fonts in Android: java.lang.RuntimeException

  19. 19

    Android [LocationManager] requestLocationUpdates(), java.lang.RuntimeException

  20. 20

    Android app java.lang.RuntimeException error

  21. 21

    Android PreferenceFragment : java.lang.RuntimeException

  22. 22

    java.lang.RuntimeException: Android Runtime error

  23. 23

    Android Boilepipe - java.lang.RuntimeException

  24. 24

    Android RuntimeException caused by java.lang.ClassNotFoundException

  25. 25

    No default constructor found; nested exception is java.lang.NoSuchMethodException

  26. 26

    java.lang.NoSuchMethodException for onCreate

  27. 27

    ProGuard java.lang.NoSuchMethodException

  28. 28

    java.lang.NoSuchMethodException for onCreate

  29. 29

    Error: java.lang.NoSuchMethodException: java.lang.Long.<init>() in spring MVC

HotTag

Archive