Firebaseui-android: NoSuchMethodException while using FirebaseRecyclerAdapter

Created on 26 Dec 2015  ·  42Comments  ·  Source: firebase/FirebaseUI-Android

I am using this library to show data in RecyclerView using FirebaseRecyclerAdapter. But app is crashing with the NoSuchMethodException.

My code is:

        mAdapter = new FirebaseRecyclerAdapter<TaskModel, TaskViewHolder>(TaskModel.class, R.layout.task_list_item, TaskViewHolder.class, firebase) {
            @Override
            protected void populateViewHolder(TaskViewHolder viewHolder, TaskModel model, int position) {
                Log.i("HOME", "populateViewHolder called");
            }
        };

        mRecyclerView.setAdapter(mAdapter);

View Helper class:

class TaskViewHolder extends RecyclerView.ViewHolder implements View.OnClickListener {

        private TextView mTimeTv;
        private TextView mTimeAmPm;
        private TextView mTaskTitleTv;

        private void findViews(View v) {
            mTimeTv = (TextView) v.findViewById(R.id.time_tv);
            mTimeAmPm = (TextView) v.findViewById(R.id.time_am_pm);
            mTaskTitleTv = (TextView) v.findViewById(R.id.task_title_tv);
        }

        public TaskViewHolder(View itemView) {
            super(itemView);
            findViews(itemView);
            itemView.setOnClickListener(this);
        }

        @Override
        public void onClick(View v) {

        }
    }

Please correct me if i am doing something wrong.

                                                                                 java.lang.RuntimeException: java.lang.NoSuchMethodException: <init> [class android.view.View]
                                                                                     at com.firebase.ui.FirebaseRecyclerAdapter.onCreateViewHolder(FirebaseRecyclerAdapter.java:168)
                                                                                     at android.support.v7.widget.RecyclerView$Adapter.createViewHolder(RecyclerView.java:5228)
                                                                                     at android.support.v7.widget.RecyclerView$Recycler.getViewForPosition(RecyclerView.java:4453)
                                                                                     at android.support.v7.widget.RecyclerView$Recycler.getViewForPosition(RecyclerView.java:4363)
                                                                                     at android.support.v7.widget.LinearLayoutManager$LayoutState.next(LinearLayoutManager.java:1961)
                                                                                     at android.support.v7.widget.LinearLayoutManager.layoutChunk(LinearLayoutManager.java:1370)
                                                                                     at android.support.v7.widget.LinearLayoutManager.fill(LinearLayoutManager.java:1333)
                                                                                     at android.support.v7.widget.LinearLayoutManager.onLayoutChildren(LinearLayoutManager.java:562)
                                                                                     at android.support.v7.widget.RecyclerView.dispatchLayout(RecyclerView.java:2900)
                                                                                     at android.support.v7.widget.RecyclerView.onLayout(RecyclerView.java:3071)
                                                                                     at android.view.View.layout(View.java:14817)
                                                                                     at android.view.ViewGroup.layout(ViewGroup.java:4631)
                                                                                     at android.support.v4.widget.SwipeRefreshLayout.onLayout(SwipeRefreshLayout.java:584)
                                                                                     at android.view.View.layout(View.java:14817)
                                                                                     at android.view.ViewGroup.layout(ViewGroup.java:4631)
                                                                                     at android.support.design.widget.CoordinatorLayout.layoutChild(CoordinatorLayout.java:1037)
                                                                                     at android.support.design.widget.CoordinatorLayout.onLayoutChild(CoordinatorLayout.java:747)
                                                                                     at android.support.design.widget.CoordinatorLayout.onLayout(CoordinatorLayout.java:761)
                                                                                     at android.view.View.layout(View.java:14817)
                                                                                     at android.view.ViewGroup.layout(ViewGroup.java:4631)
                                                                                     at android.widget.FrameLayout.layoutChildren(FrameLayout.java:453)
                                                                                     at android.widget.FrameLayout.onLayout(FrameLayout.java:388)
                                                                                     at android.view.View.layout(View.java:14817)
                                                                                     at android.view.ViewGroup.layout(ViewGroup.java:4631)
                                                                                     at android.widget.FrameLayout.layoutChildren(FrameLayout.java:453)
                                                                                     at android.widget.FrameLayout.onLayout(FrameLayout.java:388)
                                                                                     at android.view.View.layout(View.java:14817)
                                                                                     at android.view.ViewGroup.layout(ViewGroup.java:4631)
                                                                                     at android.widget.FrameLayout.layoutChildren(FrameLayout.java:453)
                                                                                     at android.widget.FrameLayout.onLayout(FrameLayout.java:388)
                                                                                     at android.view.View.layout(View.java:14817)
                                                                                     at android.view.ViewGroup.layout(ViewGroup.java:4631)
                                                                                     at android.support.v4.widget.DrawerLayout.onLayout(DrawerLayout.java:1043)
                                                                                     at android.view.View.layout(View.java:14817)
                                                                                     at android.view.ViewGroup.layout(ViewGroup.java:4631)
                                                                                     at android.widget.FrameLayout.layoutChildren(FrameLayout.java:453)
                                                                                     at android.widget.FrameLayout.onLayout(FrameLayout.java:388)
                                                                                     at android.view.View.layout(View.java:14817)
                                                                                     at android.view.ViewGroup.layout(ViewGroup.java:4631)
                                                                                     at android.widget.LinearLayout.setChildFrame(LinearLayout.java:1671)
                                                                                     at android.widget.LinearLayout.layoutVertical(LinearLayout.java:1525)
                                                                                     at android.widget.LinearLayout.onLayout(LinearLayout.java:1434)
                                                                                     at android.view.View.layout(View.java:14817)
                                                                                     at android.view.ViewGroup.layout(ViewGroup.java:4631)
                                                                                     at android.widget.FrameLayout.layoutChildren(FrameLayout.java:453)
                                                                                     at android.widget.FrameLayout.onLayout(FrameLayout.java:388)
                                                                                     at android.view.View.layout(View.java:14817)
                                                                                     at android.view.ViewGroup.layout(ViewGroup.java:4631)
                                                                                     at android.widget.LinearLayout.setChildFrame(LinearLayout.java:1671)
                                                                                     at android.widget.LinearLayout.layoutVertical(LinearLayout.java:1525)
                                                                                     at android.widget.LinearLayout.onLayout(LinearLayout.java:1434)
                                                                                     at android.view.View.layout(View.java:14817)
                                                                                     at android.view.ViewGroup.layout(ViewGroup.java:4631)
                                                                                     at android.widget.FrameLayout.layoutChildren(FrameLayout.java:453)
                                                                                     at android.widget.FrameLayout.onLayout(FrameLayout.java:388)
                                                                                     at android.view.View.layout(View.java:14817)
                                                                                     at android.view.ViewGroup.layout(ViewGroup.java:4631)
                                                                                     at android.view.ViewRootImpl.performLayout(ViewRootImpl.java:1983)
                                                                                    at android.view.ViewRootImpl.performTraversals(ViewRootImpl.java:17

Most helpful comment

There are two likely causes for this:

  1. make sure that your TaskViewHolder class is public
  2. if your TaskViewHolder is an inner class of e.g. your activity, make sure it's static

So likely

public static TaskViewHolder extends RecyclerView.ViewHolder implements View.OnClickListener {

All 42 comments

There are two likely causes for this:

  1. make sure that your TaskViewHolder class is public
  2. if your TaskViewHolder is an inner class of e.g. your activity, make sure it's static

So likely

public static TaskViewHolder extends RecyclerView.ViewHolder implements View.OnClickListener {

Note that these types of questions are typically better addressed on StackOverflow, where more people see them.

My god! So simple! Lost about four hours trying to solve this thing. Thanks @puf !

You're welcome. Which one of the two was it for you? ;-)

Number 2 :)

thank god , one day behind submission of Graduation Project

thank you guys

pro-guard still caused crash.. adding @Keep to the ViewHolder class solved for me..

Hey, I'm still having this issue. Hope we are using the same Firebase Quickstart project. Kindly help me solve it

@kirtan403 that's a good point, you need to make sure that your ViewHolder and model classes survive proguard.

@VyshnavKR are you getting a crash with proguard or without? Is your ViewHolder class public static?

I just solved it. It was proguard issue. Though I couldn't do with the
proguard on. I made it minify enabled false
On 01-Aug-2016 6:40 pm, "Sam Stern" [email protected] wrote:

@kirtan403 https://github.com/kirtan403 that's a good point, you need
to make sure that your ViewHolder and model classes survive proguard.

@VyshnavKR https://github.com/VyshnavKR are you getting a crash with
proguard or without? Is your ViewHolder class public static?


You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
https://github.com/firebase/FirebaseUI-Android/issues/46#issuecomment-236575943,
or mute the thread
https://github.com/notifications/unsubscribe-auth/AQ0s3vYW8WkC8gl35miOZE9zXChbAOMLks5qbfBOgaJpZM4G7fih
.

Thanks!

@puf , I'm not sure what I'm doing wrong. My inner class ViewHolder was already public and static, but I'm having the same issue with a view not being found. Would love to hear if you have any advice.

Here's my ViewHolder class:

     `public static class CoOpStatusHolder extends RecyclerView.ViewHolder {
      View mView;

    public CoOpStatusHolder(View itemView) {
        super(itemView);
        mView = itemView;
    }

    public void setName(String name) {
        TextView nameOfParentToChoose = (TextView) mView.findViewById(R.id.
                textView_of_parent_name_in_co_op_status);
        nameOfParentToChoose.setText(name);
    }

    public void setFacebookImage(String facebookID) {
        ProfilePictureView parentFacebookPhoto = (ProfilePictureView) mView.findViewById(R.id.
                imageview_of_parent_in_co_op_status);
        parentFacebookPhoto.setProfileId(facebookID);
    }

    public void setHours(Float numofHours) {
        TextView numOfHoursForParent = (TextView) mView.findViewById(R.id.
                textView_num_of_hours_in_co_op_other_parent_status);
        numOfHoursForParent.setText(Float.toString(numofHours));
    }


}

`

My error in the logcat is:

`09-15 20:58:17.962 17492-17492/? E/UncaughtException: java.lang.RuntimeException: java.lang.NoSuchMethodException: [class android.view.View]
at com.firebase.ui.a.d.onCreateViewHolder(Unknown Source)
at android.support.v7.widget.RecyclerView$Adapter.createViewHolder(Unknown Source)
at android.support.v7.widget.RecyclerView$Recycler.getViewForPosition(Unknown Source)
at android.support.v7.widget.RecyclerView$Recycler.getViewForPosition(Unknown Source)
at android.support.v7.widget.LinearLayoutManager$LayoutState.next(Unknown Source)
at android.support.v7.widget.LinearLayoutManager.layoutChunk(Unknown Source)
at android.support.v7.widget.LinearLayoutManager.fill(Unknown Source)
at android.support.v7.widget.LinearLayoutManager.onLayoutChildren(Unknown Source)
at android.support.v7.widget.RecyclerView.dispatchLayoutStep2(Unknown Source)
at android.support.v7.widget.RecyclerView.dispatchLayout(Unknown Source)
at android.support.v7.widget.RecyclerView.onLayout(Unknown Source)
at android.view.View.layout(View.java:16692)
at android.view.ViewGroup.layout(ViewGroup.java:5442)
at android.support.design.widget.CoordinatorLayout.c(Unknown Source)
at android.support.design.widget.CoordinatorLayout.a(Unknown Source)
at android.support.design.widget.CoordinatorLayout.onLayout(Unknown Source)
at android.view.View.layout(View.java:16692)
at android.view.ViewGroup.layout(ViewGroup.java:5442)
at android.support.design.widget.CoordinatorLayout.c(Unknown Source)
at android.support.design.widget.CoordinatorLayout.a(Unknown Source)
at android.support.design.widget.CoordinatorLayout.onLayout(Unknown Source)
at android.view.View.layout(View.java:16692)
at android.view.ViewGroup.layout(ViewGroup.java:5442)
at android.support.v4.widget.DrawerLayout.onLayout(Unknown Source)
at android.view.View.layout(View.java:16692)
at android.view.ViewGroup.layout(ViewGroup.java:5442)
at android.widget.FrameLayout.layoutChildren(FrameLayout.java:336)
at android.widget.FrameLayout.onLayout(FrameLayout.java:273)
at android.view.View.layout(View.java:16692)
at android.view.ViewGroup.layout(ViewGroup.java:5442)
at android.widget.LinearLayout.setChildFrame(LinearLayout.java:1743)
at android.widget.LinearLayout.layoutVertical(LinearLayout.java:1586)
at android.widget.LinearLayout.onLayout(LinearLayout.java:1495)
at android.view.View.layout(View.java:16692)
at android.view.ViewGroup.layout(ViewGroup.java:5442)
at android.widget.FrameLayout.layoutChildren(FrameLayout.java:336)
at android.widget.FrameLayout.onLayout(FrameLayout.java:273)
at android.view.View.layout(View.java:16692)
at android.view.ViewGroup.layout(ViewGroup.java:5442)
at android.widget.LinearLayout.setChildFrame(LinearLayout.java:1743)
at android.widget.LinearLayout.layoutVertical(LinearLayout.java:1586)
at android.widget.LinearLayout.onLayout(LinearLayout.java:1495)
at android.view.View.layout(View.java:16692)
at android.view.ViewGroup.layout(ViewGroup.java:5442)
at android.widget.FrameLayout.layoutChildren(FrameLayout.java:336)
at android.widget.FrameLayout.onLayout(FrameLayout.java:273)
at com.android.internal.policy.PhoneWindow$DecorView.onLayout(PhoneWindow.java:2707)
at android.view.View.layout(View.java:16692)
at android.view.ViewGroup.layout(ViewGroup.java:5442)
at android.view.ViewRootImpl.performLayout(ViewRootImpl.java:2173)
at android.view.ViewRootImpl.performTraversals(ViewRootImpl.java:1933)
at android.view.ViewRootImpl.doTraversal(ViewRootImpl.java:1109)
at android.view.ViewRootImpl$TraversalRunnable.run(ViewRootImpl.java:6046)
at android.view.Choreographer$CallbackRecord.run(Choreographer.java:858)
at android.view.Choreographer.doCallbacks(Choreographer.java:670)
at android.view.Choreographer.doFrame(Choreographer.java:606)
at android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:844)
at android.os.Handler.handleCallback(Handler.java:739)
at android.os.Handler.dispatchMessage(Handler.java:95)
at android.os.Looper.loop(Looper.java:152)
at android.app.ActivityThread.main(ActivityThread.java:5507)
at java.lang.reflec
09-15 20:58:18.164 17492-17492/? D/FirebaseCrashApiImpl: throwable java.lang.RuntimeException: java.lang.NoSuchMethodException: [class android.view.View]

                                                     --------- beginning of crash

09-15 20:58:18.223 17492-17492/? E/AndroidRuntime: FATAL EXCEPTION: main
Process: com.test.finalapp, PID: 17492
java.lang.RuntimeException: java.lang.NoSuchMethodException: [class android.view.View]
at com.firebase.ui.a.d.onCreateViewHolder(Unknown Source)
at android.support.v7.widget.RecyclerView$Adapter.createViewHolder(Unknown Source)
at android.support.v7.widget.RecyclerView$Recycler.getViewForPosition(Unknown Source)
at android.support.v7.widget.RecyclerView$Recycler.getViewForPosition(Unknown Source)
at android.support.v7.widget.LinearLayoutManager$LayoutState.next(Unknown Source)
at android.support.v7.widget.LinearLayoutManager.layoutChunk(Unknown Source)
at android.support.v7.widget.LinearLayoutManager.fill(Unknown Source)
at android.support.v7.widget.LinearLayoutManager.onLayoutChildren(Unknown Source)
at android.support.v7.widget.RecyclerView.dispatchLayoutStep2(Unknown Source)
at android.support.v7.widget.RecyclerView.dispatchLayout(Unknown Source)
at android.support.v7.widget.RecyclerView.onLayout(Unknown Source)
at android.view.View.layout(View.java:16692)
at android.view.ViewGroup.layout(ViewGroup.java:5442)
at android.support.design.widget.CoordinatorLayout.c(Unknown Source)
at android.support.design.widget.CoordinatorLayout.a(Unknown Source)
at android.support.design.widget.CoordinatorLayout.onLayout(Unknown Source)
at android.view.View.layout(View.java:16692)
at android.view.ViewGroup.layout(ViewGroup.java:5442)
at android.support.design.widget.CoordinatorLayout.c(Unknown Source)
at android.support.design.widget.CoordinatorLayout.a(Unknown Source)
at android.support.design.widget.CoordinatorLayout.onLayout(Unknown Source)
at android.view.View.layout(View.java:16692)
at android.view.ViewGroup.layout(ViewGroup.java:5442)
at android.support.v4.widget.DrawerLayout.onLayout(Unknown Source)
at android.view.View.layout(View.java:16692)
at android.view.ViewGroup.layout(ViewGroup.java:5442)
at android.widget.FrameLayout.layoutChildren(FrameLayout.java:336)
at android.widget.FrameLayout.onLayout(FrameLayout.java:273)
at android.view.View.layout(View.java:16692)
at android.view.ViewGroup.layout(ViewGroup.java:5442)
at android.widget.LinearLayout.setChildFrame(LinearLayout.java:1743)
at android.widget.LinearLayout.layoutVertical(LinearLayout.java:1586)
at android.widget.LinearLayout.onLayout(LinearLayout.java:1495)
at android.view.View.layout(View.java:16692)
at android.view.ViewGroup.layout(ViewGroup.java:5442)
at android.widget.FrameLayout.layoutChildren(FrameLayout.java:336)
at android.widget.FrameLayout.onLayout(FrameLayout.java:273)
at android.view.View.layout(View.java:16692)
at android.view.ViewGroup.layout(ViewGroup.java:5442)
at android.widget.LinearLayout.setChildFrame(LinearLayout.java:1743)
at android.widget.LinearLayout.layoutVertical(LinearLayout.java:1586)
at android.widget.LinearLayout.onLayout(LinearLayout.java:1495)
at android.view.View.layout(View.java:16692)
at android.view.ViewGroup.layout(ViewGroup.java:5442)
at android.widget.FrameLayout.layoutChildren(FrameLayout.java:336)
at android.widget.FrameLayout.onLayout(FrameLayout.java:273)
at com.android.internal.policy.PhoneWindow$DecorView.onLayout(PhoneWindow.java:2707)
at android.view.View.layout(View.java:16692)
at android.view.ViewGroup.layout(ViewGroup.java:5442)
at android.view.ViewRootImpl.performLayout(ViewRootImpl.java:2173)
at android.view.ViewRootImpl.performTraversals(ViewRootImpl.java:1933)
at android.view.ViewRootImpl.doTraversal(ViewRootImpl.java:1109)
at android.view.ViewRootImpl$TraversalRunnable.run(ViewRootImpl.java:6046)
at android.view.Choreographer$CallbackRecord.run(Choreographer.java:858)
at android.view.Choreographer.doCallbacks(Choreographer.java:670)
at android.view.Choreographer.doFrame(Choreographer.java:606)
at android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:844)
at android.os.Handler.handleCallback(Handler.java:739)
at android.os.Handler.dispatchMessage(Handler.java:95)
at android.os.Looper.loop(Looper.java:152)
at android.app.ActivityT`

@langsmith Are you using proguard? It screws with reflection so you have to add -keep public class CoOpStatusHolder to your proguard-rules.pro file.

@SUPERCILEX , yea I saw that recommendation on Stack Overflow posts and had that in my proguard file, but it didn't seem to make a difference.

I just moved my viewholder to a separate package/class rather than having it be an inner class. Then in my proguard file, I added -keep class com.mypackage.myapp.viewholders.** { *; }

Based on this Stack Overflow post, that move seemed to work for folks. I've uploaded my new apk to the store, so I'm just waiting for Google to refresh things before I test it.

Thanks for checking in @SUPERCILEX

@langsmith, you're welcome!

PS: just in case you didn't know, you don't have to wait for your app to update via the play store. If you click on build variants in Android Studio (left sidebar above "favorites"), you can just change the app module build type to "release." Then click "Build APK" inseate of "Generate signed APK." Generate signed APK is just a more user friendly version of build apk that configures the signingConfigs for you.

If you have any questions on how to set up your signingConfigs, just tell me and I'll show you and example gradle file that uses a keystore.properties file to sign your app.

@SUPERCILEX , thanks. My app works fine when I install it onto my phone via USB. But these Firebase errors only happen when I install it via the Play Store. So when I said/say "update", I mean that I make changes to my app and the proguard file. Then I have to update the Play Store apk to then see if the errors still happen. No matter whether I do "Build APK" or "Generate signed APK", I'll still be uploading the new APK file to the Play Store :/

I've learned a TON today with this thread and my /r/androiddev Reddit post :) 👍

You sure about needing to upload the APK to the Play Store? The release variant should be the same as what gets uploaded. Either way, I hope it works out!

Getting rid of the inner class appears to work, so I think I'm good for now. However, I'll look into release/debug more, as I need to learn more about that. Thanks

Have fun!

@langsmith glad you got the issue worked out! As others in this thread have said, you can certainly run your release build without uploading to the Play Store if you configure Android Studio correctly.

@SUPERCILEX thanks for chiming in to help here!

I still have the problem if i generete signed apk. even I

  1. make MyViewHolder class is public
  2. or make MyViewHolder is static as an inner class of my activity.

If i build using debug configuration, everything is fine

@plugie try moving your MyViewHolder class into its own file and specifically excluding it in your proguard config

@samtstern. Yes MyViewHolder is in separate file.
My minifyEnabled false. Is it mean proguard is disable right ?
Every thing is working normal in debug configuration

Yes @plugie, proguard is disabled when minifyEnabled is set to false. As @samtstern said, move your class into a separate file/package and then ignore that package name in the the proguard rules file. My proguard and Firebase are working fine with my current setup of the proguard-rules.pro file. Below's what's currently in it. Also, unless you're using Eventbus, omit the Eventbus code.

`-keepclassmembers class com.test.finalapp.Models.** { _;}
-keep class com.test.finalapp.Viewholders._* { *; }

-keep class com.firebase.* { _; }
-keep class org.apache._* { _; }
-keepnames class com.fasterxml.jackson._* { _; }
-keepnames class javax.servlet._* { _; }
-keepnames class org.ietf.jgss._* { _; }
-dontwarn org.w3c.dom._

-dontwarn org.joda.time.*
-dontwarn org.shaded.apache.
*
-dontwarn org.ietf.jgss.**
-keepattributes Signature
-keepattributes _Annotation_

//Eventbus code below:
-keepclassmembers class ** {
@org.greenrobot.eventbus.Subscribe ;
}
-keep enum org.greenrobot.eventbus.ThreadMode { *; }

//Only required if you use AsyncExecutor
-keepclassmembers class * extends org.greenrobot.eventbus.util.ThrowableFailureEvent {
(java.lang.Throwable);
}`

Thanks @langsmith.
Since I disable proguard, I don't have to set all such thing in proguard-rules.pro, right ?
I already tried to move MyViewHolder to other file/package too. But the problem still exist for release.

Below is my gradle file. Maybe there is a conflict between one to another library

apply plugin: 'com.android.application'

android {

    compileSdkVersion 24
    buildToolsVersion "24.0.2"
    defaultConfig {
        applicationId "com.plugie.ceramah"
        minSdkVersion 16
        targetSdkVersion 24
        versionCode 41
        versionName "5.1.2"
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
}

repositories {
    maven {
        url "https://s3.amazonaws.com/repo.commonsware.com"
    }
}

dependencies {
    compile fileTree(include: ['*.jar'], dir: 'libs')
    testCompile 'junit:junit:4.12'
    compile 'com.android.support:appcompat-v7:24.2.1'
    compile 'com.android.support:support-v13:24.2.1'
    compile 'com.android.support:cardview-v7:24.2.1'
    compile 'com.android.support:recyclerview-v7:24.2.1'
    compile 'com.android.support:design:24.2.1'
    compile 'com.google.firebase:firebase-messaging:9.4.0'
    compile 'com.google.firebase:firebase-ads:9.4.0'
    compile 'com.google.firebase:firebase-crash:9.4.0'
    compile 'com.firebaseui:firebase-ui:0.5.3'
    compile 'com.commonsware.cwac:wakeful:1.1.0'
    compile 'de.greenrobot:eventbus:2.4.0'
}

apply plugin: 'com.google.gms.google-services'

@plugie I think this question would be better if you posted it on StackOverflow. That's a much better environment for troubleshooting like this since we have ruled out a bug in FirebaseUI-Android as the root cause.

Thanks @samtstern. Sorry in advance.

Before I post here, I already posted the quest on StackOverflow : http://stackoverflow.com/questions/39594346/firebaserecycleradapter-give-nosuchmethodexception-if-build-using-release-keysto

Guys, problem solved after add public to MyViewHolder constructor. http://stackoverflow.com/questions/39594346/firebaserecycleradapter-give-nosuchmethodexception-if-build-using-release-keysto

It's strange the problem only exist in release build configuration.

@plugie Puf has mentioned it as its first comment in this thread. (ref: https://github.com/firebase/FirebaseUI-Android/issues/46#issuecomment-167373575)

Thanks everyone helped a lot!

@puf is a hero 🍺

Thanks man @puf :)

thank you so much @puf

Got a similar exception. My ViewHolder, Adapter and Fragment are public and are in separate files.

java.lang.RuntimeException: java.lang.NoSuchMethodException: [class com.firebase.ui.firestore.FirestoreRecyclerAdapter]
at android.arch.lifecycle.j.a(Lifecycling.java:111)
at android.arch.lifecycle.j.c(Lifecycling.java:130)
at android.arch.lifecycle.j.b(Lifecycling.java:119)
at android.arch.lifecycle.j.c(Lifecycling.java:145)
at android.arch.lifecycle.j.b(Lifecycling.java:119)
at android.arch.lifecycle.j.a(Lifecycling.java:57)
at android.arch.lifecycle.h$a.(LifecycleRegistry.java:346)
at android.arch.lifecycle.h.a(LifecycleRegistry.java:162)
at com.firebase.ui.firestore.FirestoreRecyclerAdapter.(FirestoreRecyclerAdapter.java:37)
at com.ecom.products.ProductsAdapter.(ProductsAdapter.kt:31)
at com.ecom.products.j.a(ProductsFragment.kt:48)

@ChanSek That's a different issue caused by some proguard bugs in Android Architecture Components. If you force upgrade AAC to v1.0.0, those bugs will go away.

My Current AAC is

implementation 'android.arch.lifecycle:extensions:1.0.0'
kapt 'android.arch.lifecycle:compiler:1.0.0'

my ProGuard rules are:

-keep class com.ecom.products.ProductHolder
-keep class com.ecom.products.ProductsAdapter
-keep class com.ecom.products.ProductsFragment
-keepclassmembers class com.ecom.products.ProductsFragment { *; }
-keep class com.firebase.ui.firestore.FirestoreRecyclerAdapter
-keepclassmembers class com.firebase.ui.firestore.FirestoreRecyclerAdapter { *; }

So ideally it should work. But don't know where I am missing.

@ChanSek Oh wait, I forgot overriding won't work because we use annotations which are already compiled. If this is a blocking issue for you, feel free to use this custom build:

implementation 'com.github.SUPERCILEX.FirebaseUI-Android:firebase-ui-firestore:055d5c61f3'

PS: you shouldn't need any of those proguard rules unless you're doing something funky. Also, you'd want to keep the generated class: FirestoreRecyclerAdapter_LifecycleAdapter.

@SUPERCILEX, I am not doing any funky stuff. Just because I got this exception. So thought of fixing it with these proguard rules. These are added just now to identify the root cause.

By the way, when are you folks planning to release with this fix?

@ChanSek Sweet, then you should be good to go with that custom build! 😄 As for an ETA, @samtstern would be a better person to ask.

@SUPERCILEX, gradle is failing to resolve the dependency you provided. Can you please help?

Oh, my B. Make sure to add JitPack to your list of maven repos.

@SUPERCILEX, Thanks a lot for all your help. It works fine. Waiting for the next release with this fix, so that I can remove this custom build.

By the way, it increased my build time by 30%.

Was this page helpful?
0 / 5 - 0 ratings