NoSuchMethodError: No static method create [Android] [Dagger]

Viewed 505

I have some small android libraries created for modularizing the app code. One of these libraries (libraryA) has some Activities and those are mentioned inside the AndroidManifest.xml of the library. The problem I face with this is that when I ship an SDK that is built on top of libraryA, I get the code of all the activities being shipped with libraryA even after running the proguard. This is obvious because this is how proguard works. But, I want only the activities, from libraryA, that the parent app wants to be used, to be shipped with the final apk.

To achieve the above behaviour, I have removed the activity declaration from the libraryA manifest file and added the needed activities, from libraryA, in the app's manifest file. I am also using Dagger to build my dependency graph. When I run my application after making this change, the app crashes with the following exception which seems to be a Dagger generated issue.

2020-03-28 11:28:50.081 20177-20177/? E/AndroidRuntime: FATAL EXCEPTION: main
    Process: <mypackage>, PID: 20177
    java.lang.NoSuchMethodError: No static method create(Ljavax/inject/Provider;Ljavax/inject/Provider;Ljavax/inject/Provider;Ljavax/inject/Provider;Ljavax/inject/Provider;Ljavax/inject/Provider;Ljavax/inject/Provider;)Ldagger/MembersInjector; in class Lin/apollo/android/ui/activity/MyMovedActivity_MembersInjector; or its super classes (declaration of 'in.apollo.android.ui.activity.MyMovedActivity_MembersInjector' appears in /data/app/<mypackage>-JGH6hd6Acb-8dr0QvrxKWA==/base.apk!classes5.dex)
        at in.apollo.android.di.DaggerApolloApplicationComponent$PinComponentImpl.initialize(DaggerApolloApplicationComponent.java:3267)
        at in.apollo.android.di.DaggerApolloApplicationComponent$PinComponentImpl.<init>(DaggerApolloApplicationComponent.java:3211)
        at in.apollo.android.di.DaggerApolloApplicationComponent$PinComponentImpl.<init>(DaggerApolloApplicationComponent.java:3187)
        at in.apollo.android.di.DaggerApolloApplicationComponent.pinComponent(DaggerApolloApplicationComponent.java:2650)
        at in.apollo.android.FinderApplication.onCreate(FinderApplication.java:167)
        at in.apollo.android.ApolloApplication.initializeSdk(ApolloApplication.java:264)
        at android.app.ActivityThread.handleBindApplication(ActivityThread.java:6852)
        at android.app.ActivityThread.access$1300(ActivityThread.java:268)
        at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1982)
        at android.os.Handler.dispatchMessage(Handler.java:107)
        at android.os.Looper.loop(Looper.java:237)
        at android.app.ActivityThread.main(ActivityThread.java:7807)
        at java.lang.reflect.Method.invoke(Native Method)
        at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:493)
        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1047)

Any idea why this might be happening and how can we address this?

0 Answers
Related