0

Im getting error while running RecyclerView UI

 @Override
public void onStart() {
    super.onStart();
final FirebaseRecyclerAdapter<request_recycle, requestViewHolder> firebaseRecyclerAdapter = new FirebaseRecyclerAdapter<request_recycle, requestViewHolder>(request_recycle.class, R.layout.request_trip_layout, requestViewHolder.class, query_car) {
        @Override
        protected void populateViewHolder(final requestViewHolder viewHolder, final request_recycle model, int position) {
};

}

Im getting this Error:

java.lang.RuntimeException: java.lang.NoSuchMethodException: <init> [class android.view.View]
    at com.firebase.ui.a.b.a(Unknown Source)
    at android.support.v7.widget.RecyclerView$a.b(Unknown Source)
    at android.support.v7.widget.RecyclerView$p.a(Unknown Source)
    at android.support.v7.widget.RecyclerView$p.a(Unknown Source)

Dependencies are :

 implementation 'com.google.firebase:firebase-core:16.0.1'
 implementation 'com.google.firebase:firebase-database:16.0.1' 
 implementation 'com.google.firebase:firebase-auth:16.0.1' 
 implementation 'com.google.firebase:firebase-storage:16.0.1' 
 implementation 'com.google.firebase:firebase-messaging:17.0.0' 
 implementation 'com.firebaseui:firebase-ui-database:0.4.0' 
 implementation 'com.firebaseui:firebase-ui-auth:3.1.0' 
7
  • Which version of firebase you are using . Add the dependencies with question . Do mind using java naming conventions ... Commented Jan 21, 2019 at 7:38
  • This is my dependencies implementation 'com.google.firebase:firebase-core:16.0.1' implementation 'com.google.firebase:firebase-database:16.0.1' implementation 'com.google.firebase:firebase-auth:16.0.1' implementation 'com.google.firebase:firebase-storage:16.0.1' implementation 'com.google.firebase:firebase-messaging:17.0.0' implementation 'com.firebaseui:firebase-ui-database:0.4.0' implementation 'com.firebaseui:firebase-ui-auth:3.1.0' Commented Jan 21, 2019 at 7:39
  • Try This . If problem is not solved add relevent code to question . Commented Jan 21, 2019 at 7:40
  • Sir My Dataholder public static class requestViewHolder extends RecyclerView.ViewHolder{ View mview; MediaPlayer player; public requestViewHolder(final View itemView){ super(itemView); mview=itemView; } Commented Jan 21, 2019 at 7:41
  • its already in static sir Commented Jan 21, 2019 at 7:42

1 Answer 1

0

Update both the firebaseUI dependencies to the following:

implementation 'com.firebaseui:firebase-ui-database:4.1.0'
implementation 'com.firebaseui:firebase-ui-auth:4.1.0'

So they become compatible with the firebase libraries that you are using, as it may be causing problems.

Then use the following code:

 FirebaseRecyclerOptions<request_recycle> options =
            new FirebaseRecyclerOptions.Builder<Chat>()
                    .setQuery(query_car, request_recycle.class)
                    .build();

FirebaseRecyclerAdapter adapter = new FirebaseRecyclerAdapter<request_recycle, requestViewHolder>(options) {
@Override
public ChatHolder onCreateViewHolder(ViewGroup parent, int viewType) {
    // Create a new instance of the ViewHolder, in this case we are using a custom
    // layout called R.layout.message for each item
    View view = LayoutInflater.from(parent.getContext())
            .inflate(R.layout.request_trip_layout, parent, false);

    return new ChatHolder(view);
}

@Override
protected void onBindViewHolder(ChatHolder holder, int position, Chat model) {
    // Bind the Chat object to the ChatHolder
    // ...
    }
 };

Do not forget to read the docs, and check this:

https://github.com/firebase/FirebaseUI-Android/blob/version-4.1.0/database/README.md#firebaserecycleradapter-lifecycle

You need to use adapter.startListening(); so the data can appear in the recyclerview.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.